pip and setup.py install don't install actual modules, only egg-info

1.3k views Asked by At

I've made two packages (pphp and xmlx) and distributed and uploaded them the standard way, using python setup.py sdist bdist_wheel and twine upload dist/*.

I then tried installing them using pip install, and it seemed to work fine... but then, in the interactive shell:

>>> import xmlx
Traceback (most recent call last):
  File <module>, line 1:
    import xmlx
ImportError: No module named xmlx

I then tried python setup.py install but same result (seemed fine but didn't work).

So what's going on?

1

There are 1 answers

0
jwodder On BEST ANSWER

This is the repository for xmlx, yes? Your setup.py declares the packages in your project with packages=find_packages(), but your project does not contain any import packages, only a single-file module, xmlx.py. This must be declared in your setup.py by instead writing:

py_modules=['xmlx']

(Also, dist/ and *.egg-info/ are build artifacts and should not be stored in version control; I recommend adding them to your .gitignore.)