Reputation: 107
I have a problem with a package that I just created and that I want to upload on PyPi. The structure of the package is as follows:
|- setup.py
|- README.md
|- alexandria (root folder for the package)
|- __init__.py
|- many sub-packages
the setup.py specifies the name of the package to be "alexandria-python". I wish I can call it "alexandria", but the name is already reserved on PyPi. When I first install the package locally, with "pip install -e .", it works fine. I can open Spyder or Jupyter from Anaconda, use "import alexandria", no error is returned. I can also import and use any of the sub-packages without problems.
So I then moved on uploading the package on test-Pypi. It worked fine, the package can be found at: https://test.pypi.org/project/alexandria-python/
I try to install it on my computer, using pip install -i https://test.pypi.org/simple/ alexandria-python The install seems to work ("Successfully installed alexandria-python-0.0.1"), but when I open Spyder/Jupyter and try "import alexandria", I get an error:
Traceback (most recent call last):
File "/tmp/ipykernel_24757/3637483902.py", line 1, in import alexandria
ModuleNotFoundError: No module named 'alexandria'
This is all the more strange since the package is found in the conda environment. Using the command "conda list" for instance yields:
packages in environment at /home/romain/installs/anaconda3:
Name Version Build Channel
_ipyw_jlab_nb_ext_conf 0.1.0 py39h06a4308_0
_libgcc_mutex 0.1 main
_openmp_mutex 4.5 1_gnu
alabaster 0.7.12 pyhd3eb1b0_0
alexandria-python 0.0.1 pypi_0 pypi
So the package is found.
In the end, I don't understand what can be the source of the error: problem of package structure, python path... Has anyone an idea? Thanks a lot.
Upvotes: 0
Views: 693
Reputation:
You haven't uploaded your actual package code to PyPi.
If you go here to your PyPi downloads page and then download the source distribution, you will see that it contains your .egg-info
file but not you code.
Make sure your archive file has everything it needs before uploading to PyPi.
Upvotes: 1