Django执行django-admin.py startproject mysite,报SyntaxError: invalid syntax,求教怎么处理??
环境:CentOS6.532位Python2.6.6(默认安装的)Django1.7创建项目时出现语法错误。执行django-admin.pystartprojectmy...
环境:
CentOS6.5 32位
Python 2.6.6(默认安装的)
Django 1.7
创建项目时出现语法错误。
执行django-admin.py startproject mysite
得到一下解果:
django-admin.py startproject mysite
Traceback (most recent call last):
File "/usr/bin/django-admin.py", line 5, in <module>
pkg_resources.run_script('Django==1.7', 'django-admin.py')
File "/usr/lib/python2.6/site-packages/pkg_resources.py", line 461, in run_script
self.require(requires)[0].run_script(script_name, ns)
File "/usr/lib/python2.6/site-packages/pkg_resources.py", line 1194, in run_script
execfile(script_filename, namespace, namespace)
File "/usr/lib/python2.6/site-packages/Django-1.7-py2.6.egg/EGG-INFO/scripts/django-admin.py", line 2, in <module>
from django.core import management
File "/usr/lib/python2.6/site-packages/Django-1.7-py2.6.egg/django/core/management/__init__.py", line 68
commands = {name: 'django.core' for name in find_commands(__path__[0])}
^
SyntaxError: invalid syntax
语法不熟 求教怎么解决?
重装了django1.3.7 版本,正常了。
具体原因求各位大牛分析。 展开
CentOS6.5 32位
Python 2.6.6(默认安装的)
Django 1.7
创建项目时出现语法错误。
执行django-admin.py startproject mysite
得到一下解果:
django-admin.py startproject mysite
Traceback (most recent call last):
File "/usr/bin/django-admin.py", line 5, in <module>
pkg_resources.run_script('Django==1.7', 'django-admin.py')
File "/usr/lib/python2.6/site-packages/pkg_resources.py", line 461, in run_script
self.require(requires)[0].run_script(script_name, ns)
File "/usr/lib/python2.6/site-packages/pkg_resources.py", line 1194, in run_script
execfile(script_filename, namespace, namespace)
File "/usr/lib/python2.6/site-packages/Django-1.7-py2.6.egg/EGG-INFO/scripts/django-admin.py", line 2, in <module>
from django.core import management
File "/usr/lib/python2.6/site-packages/Django-1.7-py2.6.egg/django/core/management/__init__.py", line 68
commands = {name: 'django.core' for name in find_commands(__path__[0])}
^
SyntaxError: invalid syntax
语法不熟 求教怎么解决?
重装了django1.3.7 版本,正常了。
具体原因求各位大牛分析。 展开
1个回答
展开全部
如果没记错 到Python2.7的时候才开始支持list comprehension(列表推导式)
commands = {name: 'django.core' for name in find_commands(__path__[0])}
追问
应该是 我重装了django1.3.7后恢复了
追答
祝贺 希望你早日成为django的大拿 哈哈 顶起,哦 对了 给你推荐个方案:
我用的3个版本,分别是2.5、2.7、3.x(有最新就更);而且我分别给他们各自安装在单独的virtual box虚拟机上,很方便,不担心重装电脑配置环境的问题,希望对你有用。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询