2017-04-13 113 views
0

第一次克隆回购后,我得到一个Django导入错误,我查看了以前的所有问题,但无法弄清楚我的问题是什么。 ..没有名为foo.settings的模块Django导入错误

Traceback (most recent call last): 
    File "manage.py", line 12, in <module> 
    execute_from_command_line(sys.argv) 
    File "/Library/Python/2.7/site-packages/django/core/management/__init__.py", line 353, in execute_from_command_line 
    utility.execute() 
    File "/Library/Python/2.7/site-packages/django/core/management/__init__.py", line 302, in execute 
    settings.INSTALLED_APPS 
    File "/Library/Python/2.7/site-packages/django/conf/__init__.py", line 55, in __getattr__ 
    self._setup(name) 
    File "/Library/Python/2.7/site-packages/django/conf/__init__.py", line 43, in _setup 
    self._wrapped = Settings(settings_module) 
    File "/Library/Python/2.7/site-packages/django/conf/__init__.py", line 99, in __init__ 
    mod = importlib.import_module(self.SETTINGS_MODULE) 
    File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module 
    __import__(name) 
ImportError: No module named foo.settings 

但我有我的settings.py文件在foo目录?

项目

APP1

APP 2

settings.py

wsgi.py

urls.py

APP3

manage.py

我真的很困惑。这里是我的manage.py

# !/usr/bin/env python 
import os 
import sys 


if __name__ == "__main__": 
    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "foo.settings") 

    from django.core.management import execute_from_command_line 

    execute_from_command_line(sys.argv) 
+1

你有一个'__init__.py 'foo目录中的文件? – nimasmi

+1

还是你的设置文件夹被称为'foo',而manage.py中的导入是要求'hieta'? – nimasmi

+0

@nimasmi哎哟重命名....这只是不好的后编辑。 –

回答

2

对于Python认识到一个目录作为一个模块,它需要包含一个名为__init__.py文件。该文件可以为空,也可以包含模块顶级代码。

Python documentation

__init__.py文件,才能使Python视该目录为一个包

相关SO问题:What is __init__.py for?

+0

啊!天啊。谢谢!!! –

相关问题