Django项目工作正常;重新打开并导入模块错误

时间:2012-05-26 17:53:43

标签: python django

我第一次参与Django项目,没有任何问题。我关闭了文件并重新启动计算机以进行软件更新,现在我收到以下错误:

Traceback (most recent call last):
  File "manage.py", line 14, in <module>
    execute_manager(settings)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/__init__.py", line 436, in execute_manager
setup_environ(settings_mod)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/__init__.py", line 419, in setup_environ
    project_module = import_module(project_name)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/utils/importlib.py", line 35, in import_module
__import__(name)
ImportError: No module named Stentorian

模块名称是项目的名称。我无法弄清楚导致此错误可能出错的原因。任何洞察力都会受到最高的赞赏。

编辑:这是Python sys.path:

['', '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/distribute-0.6.24-    py2.7.egg', '/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip', '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7', '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin', '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac', '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages', '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk', '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old', '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload', '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages', '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/PIL', '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg-info', '/Library/Python/2.7/site-packages']

1 个答案:

答案 0 :(得分:0)

确保此Stentorian项目目录包含__init__.py。您可以将父目录添加到Mac上PYTHONPATH的{​​{1}}环境变量中,也可以将目录添加到~/.bash_profile脚本中。 PYTHONPATH上有manage.py.是非常习惯的,在你的bash_profile中:

..

或者,在manage.py脚本中:

 PYTHONPATH=.:..:/path/to/parent:${PYTHONPATH}