Search code examples
pythonpython-3.xpypi

Module Not Found Error For Custom Pypi Package


I am trying to upload my package to pypi and use it. Using Twine i upload it to pypi but when i try to use this package I get Module not found error.
My Error : Error

My Folder structure for the package is :
folder structure

The error points to the modelpg/__init__.py , here's my modelpg/__init__.py file.

modelpg/__init__.py

Is it due to my package name is same as .py file.

EDIT 1 : My Transformer/__init__.py file
Transformer/init_.py


Solution

  • All of the imports in modelpg/__init__.py would need to either be relative:

    from .Transformer.transformer import Transformer
    

    or absolute, with the modelpg package name:

    from modelpg.Transformer.transformer import Transformer
    

    This has nothing to do with PyPI, by the way – the same applies even if the package wasn't installed from there.