Given: Python 3.4+ successfully installed in /usr/local/lib/python3.4/dist-packages module (pip3 install builders):

../builders/info.py ../builders/logger.py ../builders/modifiers.py ../builders/__init__.py ../builders/builder.py ../builders/construct.py 

Unable to import class from module:

 >>> from builders.builder import Builde Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/local/lib/python3.4/dist-packages/builders/builder.py", line 1, in <module> import construct ImportError: No module named 'construct' 

Why does an import error occur inside the module ( construct.py is imported into builder.py )?

    1 answer 1

    builders/builder.py broken in Python 3. You should use either absolute imports ( from builders import construct ) or explicit relative imports ( from . import construct ). Implicit relative import ( import construct ) is prohibited in Python 3 and was a bad practice even in Python 2.

    • On 3.4 it still did not take off, because In addition to implicit relative imports, circular import is present in the module, such imports are supported in 3.5, and in 3.5 it was possible to start the library. - Avka