I have a python package that I can use standalone just fine. When I install it to site-packages with pip, though, I lose the ability to import submodules.
My package looks like this:
mypackage
mypackage
__init__.py
mymodule.py
moduledir
__init__.py
mysubmodule.py
setup.py
If I have the package on my pythonpath, I can use it just fine. But then when I use pip to install it to site-packages, I can't import submodules.
from mypackage import mymodule # works fine
from mypackage.moduledir import mysubmodule # ModuleNotFoundError: No module named when installed to site-packages, works fine when on pythonpath
What's going on here? How do I change it so that I can import submodules?
Also, I'm sure this is answered somewhere, but I can't find it for the life of me on google or SO. I apologize if its trivial and I'm just googling the wrong terms.
Edit: Here is my setup.py as requested.
from setuptools import setup
setup(name='mypackage',
version='0.1',
description='mypackage',
url='https://gitlab.com/ericksonla/mypackage',
author='ericksonla',
author_email='[email protected]',
license='',
packages=['mypackage'],
install_requires=[],
zip_safe=False)
mypackage.moduledirdoesn't contain an__init__.py, so it's not a module.setup.pyfile. Is the distribution on PyPI?mypackagefolder, or the inner one (that containsmoduledir)? The nested folders with the same name might be confusing things if the wrong one is getting installed in the wrong place.