Search code examples
pythonpython-3.xpython-importpypi

Personal PyPI package: can't import subpackages


I've turned my personal utility functions into a package to be able to use it across all my projects. As such, I've re-structured the repo, published it on GitHub, and packaged it for PyPI.

However, I can't get it to work. I've installed it using pip install jklib, but I can't import the subpackages. For example, I get the error No module named 'jklib.django'

I've tried changing the content of all the __init__.py files with no success. I've already uploaded PyPI packages before successfully, though they didn't have subpackages.

Any ideas?


Solution

  • Use packages=setuptools.find_packages() in your setup.py to include all subpackages. There is only __init__.py in site_packages/jklib/ when installed if use packages=["jklib"].