问题描述
我刚刚安装了Django-1.5b1。我的系统配置:
- OSX 10.8
- Python 2.7.1
- Virtualenv 1.7.2
当我打电话给 django-admin.py 命令我得到以下错误
(devel)ninja Django-1.5b1:django-admin.py
有没有人有相同的错误?/ / pre>
用法: django-admin.py子命令[options] [args]
选项:
-v VERBOSITY,--verbosity = VERBOSITY
详细级别; 0 =最小输出,1 =正常输出,
2 =详细输出,3 =非常详细的输出
--settings = SETTINGS设置模块的Python路径,例如
myproject.settings.main。如果没有提供,
DJANGO_SETTINGS_MODULE环境变量将被使用
。
--pythonpath = PYTHONPATH
要添加到Python路径的目录,例如
/ home / djangoprojects / myproject。
--traceback打印追溯异常
--version显示程序的版本号并退出
-h,--help显示此帮助消息并退出
追溯(最近的呼叫最后):
文件/Users/sultan/.virtualenvs/devel/bin/django-admin.py,第5行,< module>
management.execute_from_command_line()
文件/Users/sultan/.virtualenvs/devel/lib/python2.7/site-packages/django/core/management/__init__.py,第452行, execute_from_command_line
utility.execute()
文件/Users/sultan/.virtualenvs/devel/lib/python2.7/site-packages/django/core/management/__init__.py,第375行,执行
sys.stdout.write(self.main_help_text()+'\\\
')
文件/Users/sultan/.virtualenvs/devel/lib/python2.7/site-packages/ django / core / management / __ init__.py,第241行,main_help_text
中的名称,应用程序在six.iteritems(get_commands())中:
文件/Users/sultan/.virtualenvs/devel/ lib / python2.7 / site-packages / django / core / management / __ init__.py,第108行,在get_commands
apps = settings.INSTALLED_APPS
文件/Users/sultan/.virtualenvs/devel /lib/python2.7/site-packages/django/conf/__init__.py,第52行,__getattr__
self._setup(name)
文件/Users/sultan/.virtualenvs/devel / lib目录/ pyth on2.7 / site-packages / django / conf / __ init__.py,第47行,_setup
self._wrapped =设置(settings_module)
文件/Users/sultan/.virtualenvs/devel/ lib / python2.7 / site-packages / django / conf / __ init__.py,第132行,__init__
raise ImportError(无法导入设置'%s'(在sys.path?上) %s%(self.SETTINGS_MODULE,e))
ImportError:无法导入设置的设置(在sys.path?上):没有命名设置的模块
任何人都可以建议或帮助吗?
谢谢,
Sultan
解决方案我在启动新项目时遇到了同样的问题。
我通过在命令提示符下给出这个命令来解决问题:export DJANGO_SETTINGS_MODULE =
以这种方式我取消设置指向
之前设置设置
文件(使用env | grep DJANGO_SETTINGS_MODULE
发现)在开始使用 virtualenv
在取消设置变量后,
django-admin.py
脚本的工作就像一个魅力!I've recently installed Django-1.5b1.My system configuration:
- OSX 10.8
- Python 2.7.1
- Virtualenv 1.7.2
When I call django-admin.py command I get the following error
(devel)ninja Django-1.5b1: 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 "/Users/sultan/.virtualenvs/devel/bin/django-admin.py", line 5, in <module>
management.execute_from_command_line()
File "/Users/sultan/.virtualenvs/devel/lib/python2.7/site-packages/django/core/management/__init__.py", line 452, in execute_from_command_line
utility.execute()
File "/Users/sultan/.virtualenvs/devel/lib/python2.7/site-packages/django/core/management/__init__.py", line 375, in execute
sys.stdout.write(self.main_help_text() + '\n')
File "/Users/sultan/.virtualenvs/devel/lib/python2.7/site-packages/django/core/management/__init__.py", line 241, in main_help_text
for name, app in six.iteritems(get_commands()):
File "/Users/sultan/.virtualenvs/devel/lib/python2.7/site-packages/django/core/management/__init__.py", line 108, in get_commands
apps = settings.INSTALLED_APPS
File "/Users/sultan/.virtualenvs/devel/lib/python2.7/site-packages/django/conf/__init__.py", line 52, in __getattr__
self._setup(name)
File "/Users/sultan/.virtualenvs/devel/lib/python2.7/site-packages/django/conf/__init__.py", line 47, in _setup
self._wrapped = Settings(settings_module)
File "/Users/sultan/.virtualenvs/devel/lib/python2.7/site-packages/django/conf/__init__.py", line 132, in __init__
raise ImportError("Could not import settings '%s' (Is it on sys.path?): %s" % (self.SETTINGS_MODULE, e))
ImportError: Could not import settings 'settings' (Is it on sys.path?): No module named settings
Did anyone have the same errors? Can anyone advise or help with it?
Thanks,
Sultan
I had the same issue when starting a new project.I solved the problem by giving this command at the command prompt:
export DJANGO_SETTINGS_MODULE=
in this way I unset the variable that was pointing to a "settings
" file (discovered using env | grep DJANGO_SETTINGS_MODULE
) I set before starting using virtualenv
after unsetting the variable the django-admin.py
script worked like a charm!
这篇关于Django 1.5b1:执行django-admin.py会导致“No modules named settings”错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!