我尝试在我的 Django 应用程序中运行脚本时遇到导入错误。
它与设置文件有关。
错误:
File "bookd/get_data.py", line 10, in <module>
from models import UserProfile
File "/home/hiccup/DataProjects/goodread/bookda/bookd/models.py", line 3, in <module>
from django.db import models
File "/usr/local/lib/python2.7/dist-packages/django/db/__init__.py", line 14, in <module>
if not settings.DATABASES:
File "/usr/local/lib/python2.7/dist-packages/django/utils/functional.py", line 276, in __getattr__
self._setup()
File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line 42, in _setup
self._wrapped = Settings(settings_module)
File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line 89, in __init__
raise ImportError("Could not import settings '%s' (Is it on sys.path?): %s" % (self.SETTINGS_MODULE, e))
ImportError: Could not import settings 'bookda.settings' (Is it on sys.path?): No module named bookda.settings
我知道这是一个非常基本的错误,并且有解决它的答案,但我无法解决它,无论我尝试以哪种方式添加设置工作的路径。而且我系统上的其他 django 应用程序运行良好,这相当令人沮丧。
等级制度:
bookda/settings.py
bookda/books/script.py
运行 script.py 时出现错误。