2016-09-09 228 views
0

我安裝了python 2.7和3.5。在創建django項目時,我選擇了Python 3.5作爲我的python解釋器。我還安裝了rest框架,但是在運行我的django項目時發現了這個錯誤。幫助ImportError:沒有模塊名rest_framework

Traceback (most recent call last): 
    File "manage.py", line 22, in <module> 
    execute_from_command_line(sys.argv) 
    File "/Library/Python/2.7/site-packages/Django-1.10-py2.7.egg/django/core/management/__init__.py", line 367, in execute_from_command_line 
    utility.execute() 
    File "/Library/Python/2.7/site-packages/Django-1.10-py2.7.egg/django/core/management/__init__.py", line 341, in execute 
    django.setup() 
    File "/Library/Python/2.7/site-packages/Django-1.10-py2.7.egg/django/__init__.py", line 27, in setup 
    apps.populate(settings.INSTALLED_APPS) 
    File "/Library/Python/2.7/site-packages/Django-1.10-py2.7.egg/django/apps/registry.py", line 85, in populate 
    app_config = AppConfig.create(entry) 
    File "/Library/Python/2.7/site-packages/Django-1.10-py2.7.egg/django/apps/config.py", line 90, in create 
    module = import_module(entry) 
    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 rest_framework 
+0

你在使用virtualenv嗎?如果是的話,確保你已經激活了virtualenv – arcegk

+0

你說你選擇了python3.5,但是錯誤顯示它正在運行python2.7。你確定我已經正確選擇瞭解釋器嗎? –

回答

0

對不起。我執行命令python manage.py runserver而不是python3 manage.py runserver

現在正常工作。

相關問題