ImportError: unable to import name ABCMeta - Python error in PyDev on Linux

I came across this strange error when writing code using PyDev on Linux. Even simple code like this causes an error

print 'Hello World' 

and the error is here

 True Traceback (most recent call last): File "/usr/lib/python2.7/site.py", line 62, in <module> import os File "/usr/lib/python2.7/os.py", line 398, in <module> import UserDict File "/usr/lib/python2.7/UserDict.py", line 83, in <module> import _abcoll File "/usr/lib/python2.7/_abcoll.py", line 11, in <module> from abc import ABCMeta, abstractmethod ImportError: cannot import name ABCMeta 

my module is called sample.py. Please help me. Thanks

+6
source share
2 answers

I assume that you have a file named abc.py or abc.pyc in your working directory or PYTHONPATH, and this is a shadow for the stdlib abc module.

+19
source

Most likely your python script file name is "abc" and "abc" is the module of the python standard library.

Change the file name and run the script again, the error will be removed, and the script will work fine.

0
source

Source: https://habr.com/ru/post/913882/


All Articles