I do my first steps in python package distributions.
Unfortunately, I have ModuleNotFoundError after successful install from pip.
My dirs layout is pretty simple:
maindir
   |- setup.py
   |- pysoft
         |- __init__.py
         |- main.py
         |- pylib.py
main.py:
import pylib
def main():
    print("main program")
    pylib.libfunc()
if __name__ == '__main__':
    main()
pylib.py:
def libfunc():
    print("lib func")
setup.py:
import setuptools
setuptools.setup(
    name='pysoft',
    version='0.0.21',
    author='als',
    author_email='[email protected]',
    description='deploy tester',
    py_modules=['pylib'],
    packages=setuptools.find_packages(),
    python_requires='>=3.6',
    entry_points={
        'console_scripts': [
            'pysoft = pysoft.main:main',
        ],
    },
)
I do packaging and uploading to test.pypi.org:
python3 setup.py sdist bdist_wheel
python3 -m twine upload --repository-url https://test.pypi.org/legacy/ dist/*
I setup and start new virtualenv and install my package:
 python3 -m pip install -i https://test.pypi.org/simple/ pysoft
Then I try to run it, but got error:
pysoft 
Traceback (most recent call last):
  File "/home/fat/buff/tt/bin/pysoft", line 5, in <module>
    from pysoft.main import main
  File "/home/fat/buff/tt/lib/python3.6/site-packages/pysoft/main.py", line 1, in <module>
    import pylib
ModuleNotFoundError: No module named 'pylib'
Could you figure out where I have wrong step?
You do import pylib as if said pylib is a top-level module or package. But it's not — it's a submodule of the package pysoft. For the proper import do:
from pysoft import pylib
py_modules=['pylib'] in your setup.py is ignored because setuptools cannot find top-level pylib.py. But packages=setuptools.find_packages() works and include pysoft package into distributions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With