简体   繁体   中英

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?

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"] .

Old question, but still interesting. I own a function collection too on Github called ofunctions , and have created a "namespace" package which will install everything, and subpackages which will only install the necessary functions, including its dependencies.

I've managed to create a single setup.py file which deals with the pacakge itself, and all subpackages and requirements. In the end, I wanted to achieve the following install syntax to install just a part of the pacakge:

pip install ofunctions.network

Or the whole pacakge via

pip install ofunctions

Have a look at my git repo construction if it helps. Best regards.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM