无法运行django-admin startproject mysite(ubuntu,django.core.exceptions.ImproperlyConfigured)

时间:2015-06-07 21:50:50

标签: python django ubuntu django-admin

当我尝试运行" django-admin startproject mysite"出现错误:

django-admin startprojekt mysite

Traceback (most recent call last):
  File "/usr/local/bin/django-admin", line 11, in <module>
    sys.exit(execute_from_command_line())
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 338, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 330, 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 182, in fetch_command
    settings.INSTALLED_APPS
  File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line 48, in __getattr__
    self._setup(name)
  File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line 42, in _setup
    % (desc, ENVIRONMENT_VARIABLE))
django.core.exceptions.ImproperlyConfigured: Requested setting INSTALLED_APPS, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.

这是Ubuntu 15.04的全新安装。

默认情况下我安装了python 2和3:

python:

Python 2.7.9 (default, Apr  2 2015, 15:33:21) 


python3:

Python 3.4.3 (default, Mar 26 2015, 22:03:40) 

我已经通过pip安装了django(sudo pip install Django)。

似乎安装了Django:

python -c "import django; print(django.get_version())"
1.8.2

python3 -c "import django; print(django.get_version())"
1.7.6

有什么不对?

1 个答案:

答案 0 :(得分:4)

您的startproject拼写错误startprojekt。尝试:

django-admin startproject mysite