django sudo runserver启动错误 [英] django sudo runserver kicking up an error

查看:112
本文介绍了django sudo runserver启动错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试运行 sudo ./manage.py runserver 时,我收到以下错误:

 追溯(最近的最后一次呼叫):
文件./manage.py,第9行,< module>
execute_from_command_line(sys.argv)
文件/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py,第429行,execute_from_command_line
utility.execute()
文件/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py,第379行,执行
self.fetch_command (子命令).run_from_argv(self.argv)
文件/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py,第252行,fetch_command
app_name = get_commands()[subcommand]
文件/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py,第101行,在get_commands
apps = settings.INSTALLED_APPS
文件/usr/local/lib/python2.7/dist-packages/django/utils/functional.py,第276行,__getattr__
self._setup()
文件/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py,第42行_setup
self._wrapped =设置(settings_module)
文件/ usr / local / lib / py thon2.7 / dist-packages / django / conf / __ init__.py,第139行,__init__
logging_config_func(self.LOGGING)
文件/usr/lib/python2.7/logging/config .py,第776行,dictConfig
dictConfigClass(config).configure()
文件/usr/lib/python2.7/logging/config.py,第562行,配置
'filter%r:%s'%(name,e))
ValueError:无法配置过滤器'require_debug_false':无法解析'django.utils.log.RequireDebugFalse':没有名为RequireDebugFalse的模块

运行 ./ manage.py runserver 非常好。



有点挖掘,我发现这可能与Django1.3错误有关?但是,我在一个运行Django 1.4 pre-alpha的virtualenv。



我需要sudo命令的原因是因为我正在尝试从80端口运行服务器需要sudo。

解决方案

当您运行 manage.py sudo 它不使用激活的虚拟环境。您可以使用virtualenv中的python可执行文件运行,例如:

  $ sudo /home/USER/.virtualenvs/YOUR_PROJECT/bin/python manage.py runserver 

您可以从virtualenv获取python可执行路径:

  $ python 


When I try to run sudo ./manage.py runserver, I get the following error:

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

Running ./manage.py runserver works perfectly fine.

Doing a bit of digging around, I found that this might be related to a Django1.3 bug? However, I'm in a virtualenv running Django 1.4 pre-alpha.

The reason why I need the sudo command is because I'm trying to runserver from port 80 which requires sudo.

解决方案

When you run manage.py with sudo it does not use activated virtual env. Most probably, you have another version of django installed outside virtualenv.

You can run using the python executable from virtualenv, ie:

$ sudo /home/USER/.virtualenvs/YOUR_PROJECT/bin/python manage.py runserver

You can get python executable path from virtualenv:

$ which python

这篇关于django sudo runserver启动错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆