错误:无法导入设置'settings'(它是否在sys.path上?是否有语法错误?):没有模块命名设置

时间:2015-07-24 10:11:45

标签: python django

我正在使用django 1.2.2版本的django项目。我正在尝试使用manage.py或django-admin.py运行服务器,但我收到错误

Error: Could not import settings 'settings' (Is it on sys.path? Does it have syntax errors?): No module named settings

settings.py文件存在于manage.py和wsgi.py所在的同一目录中。我通过将设置作为参数传递来尝试它

django-admin.py runserver --settings=settings.py

但我仍然得到同样的错误

Error: Can't find the file 'settings.py' in the directory
containing 'manage.py'. It appears you've customized things.
You'll have
to run django-admin.py, passing it your settings module.
(If the
file settings.py does indeed exist, it's causing an ImportError
somehow.

我第一次使用django 1.2。帮助将是适当的

2 个答案:

答案 0 :(得分:0)

尝试正确设置DJANGO_SETTINGS_MODULE环境变量

export DJANGO_SETTINGS_MODULE=settings

或运行django-admin如下

django-admin.py runserver --settings=settings

答案 1 :(得分:0)

为什么不跑?

./ manage.py runserver