赢7 + python 2.7 + django 1.5.8
我不知道我用我的电脑做了什么,但昨天django-admin.py startproject
正在工作。我如何解决它?谢谢你的时间。
c:\Python27\Scripts>django-admin.py
Usage: django-admin.py subcommand [options] [args]
Options
-v VERBOSITY, --verbosity=VERBOSITY
Verbosity level; 0=minimal output, 1=normal output,
2=verbose output, 3=very verbose output
-settings=SETTINGS The Python path to a settings module, e.g.
"myproject.settings.main". If this isn't provided, the
DJANGO_SETTINGS_MODULE environment variable will be
used.
--pythonpath=PYTHONPATH
A directory to add to the Python path, e.g.
"/home/djangoprojects/myproject".
--traceback Print traceback on exception
--version show program's version number and exit
-h, --help show this help message and exit
Traceback (most recent call last)
File "C:\Python27\Scripts\django-admin.py", line 5, in <module>
management.execute_from_command_line()
File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line
453, in execute_from_command_line
utility.execute()
File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line
376, in execute
sys.stdout.write(self.main_help_text() + '\n')
File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line
242, in main_help_text
for name, app in six.iteritems(get_commands()):
File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line
109, in get_commands
apps = settings.INSTALLED_APPS
File "C:\Python27\lib\site-packages\django\conf\__init__.py", line 53, in __ge
tattr__
self._setup(name)
File "C:\Python27\lib\site-packages\django\conf\__init__.py", line 48, in _set
up
self._wrapped = Settings(settings_module)
File "C:\Python27\lib\site-packages\django\conf\__init__.py", line 134, in __i
nit__
raise ImportError("Could not import settings '%s' (Is it on sys.path?): %s"
% (self.SETTINGS_MODULE, e))
ImportError: Could not import settings 'mysite.settings' (Is it on sys.path?): N
o module named settings
c:\Python27\Scripts>
答案 0 :(得分:2)
你做的是添加一个环境变量DJANGO_SETTINGS_MODULE=mysite.settings
,然后卸载模块或者昨天你曾经只在{{1}的特定目录中运行django-admin.py
命令。找到了。
解决这个问题:
解决方案1 :删除DJANGO_SETTINGS_MODULE环境变量(我建议这样做)
解决方案2 :从昨天运行的目录中运行mysite
命令
Sollution 3 :明确运行django-admin.py
但实际上,无论如何只做1。它是那样的理智。
如果您不知道如何删除环境变量,请查看Google,这很简单,无论如何您应该记住它,因为您昨天做过:P(或查看此{{ 3}}