0

I followed this tutorial from python.org and managed to upload to PyPI and install with pip but all I get is

ModuleNotFoundError: No module named 'tomaszslittlehelpers'

Any suggestions?

The import works locally that is when imported from a file in a folder above.

package name is tomaszslittlehelpers

setup.py:

import setuptools

with open('README.md', 'r') as fh:
    long_description = fh.read()

setuptools.setup(
        name='tomaszslittlehelpers',
        version='0.0.2',
        author='TomaszAndrzej',
        author_email='',
        description='Tomasz\'s Little Helpers',
        long_description=long_description,
        long_description_content_type='text/markdown',
        url='',
        packages=setuptools.find_packages(),
        classifiers=[
                'Programming Language :: Python :: 3',
                'License :: OSI Approved :: MIT License',
                'Operating System :: OS Independent',
                ],
        python_requires='>=3.7',

        )

__init__.py:

name='tomaszslittlehelpers'

Project tree:

tomaszslittlehelpers
    build
        bdist.win-amd64
    dist
        tomaszslittlehelpers-0.0.2-py3-none-any.whl
        tomaszslittlehelpers-0.0.2.tar.gz
    tomaszslittlehelpers.egg-info
        dependency_links.txt
        PKG-INFO
        SOURCES.txt
        top_level.txt
    __init__.py
    LICENSE
    README.md
    setup.py

pip install tomaszslittlehelpers
installs into

C:\users ... \python37\Lib\site-packages\tomaszslittlehelpers-0.0.1.dist-info there is no tomaszslittlehelpers folder

6
  • 2
    Hi @Tomasz. It'd be good to get more specifics on this. What is the package called on PyPI? Please also share the setup.py file so we can see how you're attempting to build it. Commented Oct 1, 2019 at 22:49
  • It sounds like an issue with the location of the installed package. I can see the package on pypi.org so it must be an issue with where the package is installed locally. Commented Oct 1, 2019 at 22:50
  • where does it install to Commented Oct 1, 2019 at 23:03
  • Somewhere along the way you did something like python setup.py build to create an archive in dist/ that you uploaded, right? I'd bet that the package you created has no Python files in it because setuptools.find_packages() didn't find anything. Commented Oct 1, 2019 at 23:26
  • If you can show the directory tree of your project that would help. You probably want an empty tomaszslittlehelpers/__init__.py in your package. Commented Oct 2, 2019 at 0:57

2 Answers 2

10
+25

There is an issue with your packaging. Your code is not added to your distributions. You are using packages=setuptools.find_packages(), but there doesn't seem to be any package to look for. It looks like your code is in the __init__.py file at the root of your project. This most likely won't work.

Two solutions:

  • Rename your __init__.py to tomaszslittlehelpers.py and replace packages=setuptools.find_packages(), with py_modules=['tomaszslittlehelpers'],.

  • Move your __init__.py to a tomaszslittlehelpers subdirectory, and find_packages() should be able to find it.

In both cases you should then be able to import your code like this: import tomaszslittlehelpers.

Sign up to request clarification or add additional context in comments.

Comments

-1

If you look on pypi and download your release You can see that in this release there are no python files included

As @kirk-strauser mentioned. This is most likely because setuptools.find_packages() didn't find any packages

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.