当我尝试运行sudo ./manage.py runserver
时,出现以下错误:
Traceback (most recent call last):
File "./manage.py", line 9, in <module>
execute_from_command_line(sys.argv)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 429, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 379, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 252, in fetch_command
app_name = get_commands()[subcommand]
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 101, in get_commands
apps = settings.INSTALLED_APPS
File "/usr/local/lib/python2.7/dist-packages/django/utils/functional.py", line 276, in __getattr__
self._setup()
File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line 42, in _setup
self._wrapped = Settings(settings_module)
File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line 139, in __init__
logging_config_func(self.LOGGING)
File "/usr/lib/python2.7/logging/config.py", line 776, in dictConfig
dictConfigClass(config).configure()
File "/usr/lib/python2.7/logging/config.py", line 562, in configure
'filter %r: %s' % (name, e))
ValueError: Unable to configure filter 'require_debug_false': Cannot resolve 'django.utils.log.RequireDebugFalse': No module named RequireDebugFalse
正常运行./manage.py runserver
非常合适。
进行一些挖掘,我发现这可能与Django1.3错误有关?但是,我正在运行Django 1.4 pre-alpha。
我需要sudo命令的原因是因为我试图从端口80运行服务器,这需要sudo。
答案 0 :(得分:15)
当您使用manage.py
运行sudo
时,它不会使用已激活的虚拟环境。最有可能的是,你在virtualenv之外安装了另一个版本的django。
您可以使用virtualenv中的python可执行文件运行,即:
$ sudo /home/USER/.virtualenvs/YOUR_PROJECT/bin/python manage.py runserver
你可以从virtualenv获取python可执行文件路径:
$ which python