2016-09-09 152 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

现在正常工作。

相关问题