我将 Python 3.7.3 与 PyCharm 结合使用。当我尝试将 abc 包导入到我的项目中时,我收到此错误,然后是 Python 意外退出 警告对话框:
Fatal Python error: init_sys_streams: can't initialize sys standard streams
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/io.py", line 52, in <module>
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/abc.py", line 166, in <module>
NameError: name 'ABCMeta' is not defined
Abort trap: 6
一开始我并没有太在意这个错误,还以为是我代码写错了。所以我评论了 import abc 行。但是错误并没有消失。此外,每次我运行 python3 程序时,我都会遇到同样的错误。即使在终端:
- 之前我安装了 Anaconda,但后来卸载了它。
- 在我的项目中,我正在使用
pipenv - 我也有 python 2,但我没有使用它。我尝试运行它并没有出现这样的错误。
- 以前我尝试过以多种方式安装
vptyhon。那时我还不知道pip,所以我可能会搞砸框架。
请您参考如下方法:
删除 /Library/Frameworks/Python.framework 文件并重新安装 python 3.7.3 解决了错误
