gpt4 book ai didi

python - Django 1.5b1 : executing django-admin. py导致 "No module named settings"错误

转载 作者:太空狗 更新时间:2023-10-29 17:11:24 25 4
gpt4 key购买 nike

我最近安装了 Django-1.5b1。我的系统配置:

  • 操作系统 10.8
  • python 2.7.1
  • 虚拟环境 1.7.2

当我调用 django-admin.py 命令时,出现以下错误

(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

有没有人有同样的错误?有人可以提供建议或帮助吗?

谢谢,

苏丹

最佳答案

我在开始一个新项目时遇到了同样的问题。我通过在命令提示符下给出这个命令解决了这个问题:

export DJANGO_SETTINGS_MODULE=

通过这种方式,我取消了指向“settings”文件的变量(使用 env | grep DJANGO_SETTINGS_MODULE 发现)我在开始使用 virtualenv 之前设置

取消设置变量后,django-admin.py 脚本运行得非常棒!

关于python - Django 1.5b1 : executing django-admin. py导致 "No module named settings"错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13775780/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com