我面临的问题与此类似: PyCharm not using my configured virtualenv interpreter
我正在尝试在虚拟环境中的PyCharm中运行python模块。我已经设置了正确的项目解释器和Python解释器,以指向VirtualEnv解释器。我设置不正确吗?
Python解释器:
/projects/DE/.env/bin/python -m training
Could not import runpy module
Traceback (most recent call last):
File "/Users/deepak/anaconda/lib/python3.6/runpy.py", line 14, in <module>
import importlib.machinery # importlib first so we can test #15386 via -m
File "/projects/DE/.env/lib/python3.6/importlib/__init__.py", line 57, in <module>
import types
File "/projects/DE/training/types.py", line 2, in <module>
import json
File "/Users/deepak/anaconda/lib/python3.6/json/__init__.py", line 106, in <module>
from .decoder import JSONDecoder, JSONDecodeError
File "/Users/deepak/anaconda/lib/python3.6/json/decoder.py", line 3, in <module>
import re
File "/projects/DE/.env/lib/python3.6/re.py", line 122, in <module>
import enum
File "/projects/DE/.env/lib/python3.6/enum.py", line 2, in <module>
from types import MappingProxyType, DynamicClassAttribute
ImportError: cannot import name 'MappingProxyType'```
我不确定PyCharm为什么使用Anaconda python。我不确定是否还有其他地方需要更改解释器以指向virtualenv。
当我从终端运行时,同一命令(/projects/DE/.env/bin/python -m training
)似乎起作用。
我可以进行哪些更改,以便可以从PyCharm运行模块?