Search code examples
pythonpython-3.xnameerror

Running python code give NameError: name 'ABCMeta' is not defined every time


I'm using Python 3.7.3 with PyCharm. When I tried to import abc package into my project I got this error followed with Python quit unexpectedly alert dialog:

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

At first I didn't pay much attention to the error and thought I made a mistake in the code. So I commented import abc line. But the error didn't disappear. Moreover, each time I was running python3 programs I was getting the same error. Even in terminal:

terminal python3 error

  • Previously I had Anaconda installed, but uninstalled it later.
  • In my project I'm using pipenv
  • I also have python 2 but I don't use it. I tried to run it and there was no such error.
  • Previously I tried to install vptyhon in many ways. I didn't know about pip then, so I could mess up the framework.

Solution

  • Removing /Library/Frameworks/Python.framework file and reinstalling python 3.7.3 resolved the error