2017-09-04 102 views
2

當我試圖運行python manage.py runserver命令我得到這個錯誤:Django的:沒有模塊名爲設置

Traceback (most recent call last): 
    File "manage.py", line 22, in <module> 
    execute_from_command_line(sys.argv) 
    File "/Users/user/lokvi/lokvi_env/lib/python2.7/site-packages/django/core/management/__init__.py", line 363, in execute_from_command_line 
    utility.execute() 
    File "/Users/user/lokvi/lokvi_env/lib/python2.7/site-packages/django/core/management/__init__.py", line 307, in execute 
    settings.INSTALLED_APPS 
    File "/Users/user/lokvi/lokvi_env/lib/python2.7/site-packages/django/conf/__init__.py", line 56, in __getattr__ 
    self._setup(name) 
    File "/Users/user/lokvi/lokvi_env/lib/python2.7/site-packages/django/conf/__init__.py", line 41, in _setup 
    self._wrapped = Settings(settings_module) 
    File "/Users/user/lokvi/lokvi_env/lib/python2.7/site-packages/django/conf/__init__.py", line 110, 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 settings 

我有蟒蛇2.7在我的virtualenv。我注意到奇怪的事情在我的堆棧跟蹤的上次行,最後行前面具有路徑是這樣說:/lokvi_env/lib/python2.7

但最後一行是這樣認爲System/Library/Frameworks等,所以它看起來像路徑已經從virtualenv到系統。可以嗎?

+0

似乎有路徑不匹配..你使用的是Windows嗎? –

+0

@MohideenibnMohammed,你的激活virtualenv嗎? – yerassyl

+0

? –

回答

3

您需要導入settings模塊

from django.conf import settings 
0

哦,這不是Python路徑具體問題,不好意思。我只需要__init__.py在設置模塊裏面我的項目,因爲沒有設置它試圖找到它在Python本身,並不能,我相信。

相關問題