Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

django sudo runserver kicking up an error

Tags:

django

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.

like image 293
super9 Avatar asked Dec 06 '11 15:12

super9


1 Answers

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
like image 151
bmihelac Avatar answered Oct 26 '22 11:10

bmihelac