我尝试在我的共享托管环境中安装django,该环境具有SSH访问权限。
我使用
下载了最新版本的Djangosvn export http://code.djangoproject.com/svn/django/trunk/django django
我可以在python shell中导入Django而不会抛出任何错误。
但后来我尝试使用django-admin.py开始一个新项目,它开始给我一些错误,我在过去几个小时试图谷歌。我还是找不到它
以下是实际错误:
k4660061@server42222:~$ django-admin.py startproject klikevent
/u/k4660061/home/local/lib/python/site-packages/django/core/management/templates.py:155: Warning: 'with' will become a reserved keyword in Python 2.6
Traceback (most recent call last):
File "/u/k4660061/home/local/lib/python/site-packages/django/bin/django-admin.py", line 5, in <module>
management.execute_from_command_line()
File "/u/k4660061/home/local/lib/python/site-packages/django/core/management/__init__.py", line 442, in execute_from_command_line
utility.execute()
File "/u/k4660061/home/local/lib/python/site-packages/django/core/management/__init__.py", line 381, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/u/k4660061/home/local/lib/python/site-packages/django/core/management/__init__.py", line 261, in fetch_command
klass = load_command_class(app_name, subcommand)
File "/u/k4660061/home/local/lib/python/site-packages/django/core/management/__init__.py", line 69, in load_command_class
module = import_module('%s.management.commands.%s' % (app_name, name))
File "/u/k4660061/home/local/lib/python/site-packages/django/utils/importlib.py", line 35, in import_module
__import__(name)
File "/u/k4660061/home/local/lib/python/site-packages/django/core/management/commands/startproject.py", line 2, in <module>
from django.core.management.templates import TemplateCommand
File "/u/k4660061/home/local/lib/python/site-packages/django/core/management/templates.py", line 155
with open(old_path, 'r') as template_file:
^
SyntaxError: invalid syntax
k4660061@server42222:~$
由于
更新
经过一夜安眠,我开始工作了!见伯尼的回答。我必须一遍又一遍地看到堆栈跟踪,但我只需要将import语句添加到多个文件文件是
的django / utils的/ archive.py django的/型芯/管理/ templates.py
以及任何抛出警告with_statement
的文件谢谢@Bernie
答案 0 :(得分:1)
如果语法错误与with
语句有关,则可能是您的prod服务器的旧版本的Python比您的开发服务器更新。
如果您的prod服务器运行的是2.5或更高版本,您可以这样做:
from __future__ import with_statement
请注意:任何from __future__
导入必须是第一个导入。
参考:http://docs.python.org/reference/simple_stmts.html#future