我尝试在具有 SSH 访问权限的共享主机环境上安装 django。
我使用下载了最新版本的 Django
svn 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:~$
谢谢
更新
经过一夜好眠,我开始工作了!见伯尼的回答。我必须一遍又一遍地查看堆栈跟踪,但我只需要将导入语句添加到多个文件中
该文件是
django/utils/archive.py django/core/management/templates.py
以及任何抛出警告 with_statement 的文件
谢谢@伯尼