我安装了python 2.7和3.5。在创建django项目时,我选择了Python 3.5作为我的python解释器。我还安装了休息框架,但是在运行我的django项目时发现了这个错误。帮助
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 :(得分:0)
python manage.py runserver
而不是python3 manage.py runserver
现在工作正常。