I got an example code that uses the abc package for python. I installed abc in my laptop using pip. The route to the package folder is correctly set the in PATH.
The example code that I got does:
'from abc import ABC, abstractmethod'
If I try to run it, I got 'ImportError: cannot import name ABC'. However, if I tried to import only 'abstractmethod' the import works.
I'm also able to import ABCMeta, just not ABC.
'from abc import ABC' <- dont work
'from abc import ABCMeta, abstractmethod' <- it does
It seems to be within the same package, and I didn't get error messages when I installed the package via pip. So, why I can import 'ABCMeta' and 'abstractmethod' but not 'ABC'?
I found exactly what I was looking for here:
http://www.programmersought.com/article/7351237937/
Basically, in python 2.7 (which is the version I have to use because boss reasons) you use ABCMeta instead and you set your class to inherit from ABCMeta like:
from abc import ABCMeta, abstractmethod
class MyBase():
__metaclass__ = ABCMeta
@abstractmethod
def func(self):
This was very helpful to me and I hope is for others.