无效的应用名称Django-CMS

时间:2015-03-27 07:03:39

标签: python django debian pip django-cms

在Raspbian上使用带有内核3.18.7,python3,pip3的Django-CMS 3.0安装文档。我跑的时候

djangocms -p . mysite

我明白了:

~/django/env$ sudo djangocms -p . mysite
Traceback (most recent call last):
  File "/usr/local/bin/djangocms", line 9, in <module>
    load_entry_point('djangocms-installer==0.7.2', 'console_scripts', 'djangocms')()
  File "/usr/lib/python3/dist-packages/pkg_resources.py", line 337, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/usr/lib/python3/dist-packages/pkg_resources.py", line 2280, in load_entry_point
    return ep.load()
  File "/usr/lib/python3/dist-packages/pkg_resources.py", line 1990, in load
    entry = __import__(self.module_name, globals(),globals(), ['__name__'])
  File "/usr/local/lib/python3.2/dist-packages/djangocms_installer/main.py", line 8, in <module>
    from . import config, django, install
  File "/usr/local/lib/python3.2/dist-packages/djangocms_installer/config/__init__.py", line 101
    sys.stderr.write(u"Project name '%s' is not a valid app name, "
SyntaxError: invalid syntax

注意:我是从~/django/env运行它。

2 个答案:

答案 0 :(得分:0)

Python3不喜欢DjangoCMS 3使用的unicode助手:

# First of all, check if the project name is valid
if not validate_project(args.project_name):
    sys.stderr.write(u"Project name '%s' is not a valid app name, "
                     u"or it's already defined. "
                     u"Please use only numbers, letters and underscores.\n"
                     % args.project_name)
    sys.exit(3)

字符串之前的'u'为python 3提供了synxtax错误。您可以直接在该文件中修复它,检查Django CMS并要求修复,或者使用较低的python版本,如2.7

这很奇怪,因为看来DjangoCMS受python3 https://www.djangopackages.com/python3/支持

我刚刚使用python3.2解释器进行了一些测试:

>>> sys.stderr.write(u"Hello ")
  File "<stdin>", line 1
    sys.stderr.write(u"Hello ")
                             ^
SyntaxError: invalid syntax
>>> sys.stderr.write("Hello ")
6
Hello >>> 

答案 1 :(得分:0)

您应该将Python版本更新为3.3或3.4。 django CMS和djangocms-installer都不支持Python 3.2。

正如@lapinkoira建议的那样,您看到的具体问题归因于u'' - 前缀。但是,这些已经被Python 3.3带回来,以便更容易支持Python 2.6+和Python 3.3+(另请参阅PEP 414