我已将Project Interpreter设置为`python 3.5.2`,但似乎我的项目仍然使用`python 2.7`

时间:2017-11-08 03:06:36

标签: python django pycharm

我已将项目口译员设置为python 3.5.2,请注意只有两个包python 3.5.2具有:

enter image description here

但是当我运行runserver时,我的项目仍然使用python 2.7

enter image description here

追溯:

File "/Library/Python/2.7/site-packages/Django-1.11.2-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.11.2-py2.7.egg/django/apps/config.py", line 94, 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_auth

修改

我的项目运行/调试配置也是3.5.2

enter image description here

1 个答案:

答案 0 :(得分:0)

正如评论中提到的@Sraw,您将直接从终端启动应用程序,但不会点击“运行”按钮。

如果你想从pycharm启动django,请遵循本教程 (此功能仅在专业版中受支持。)
https://www.jetbrains.com/help/pycharm/step-4-creating-and-running-your-first-django-project.html

最佳解决方案是使用带或不带pycharm的虚拟环境

与pycharm
在pycharm中配置Python虚拟环境
https://www.jetbrains.com/help/pycharm/configuring-python-interpreter.html

没有pycharm
http://docs.python-guide.org/en/latest/dev/virtualenvs/#lower-level-virtualenv