ModuleNotFoundError despite declairing install_requires in setup.py

Question:

I wrote create a package uploaded to PyPI for testing, but I keep getting a ModuleNotFoundError for pandas when I try to import it to a virtual environment. I import pandas in a file in the package and therefore, declared it in setup.py under install_requires = ['pandas']. Before that, I had a setup.cfg and declared it in pyproject.toml

[build-system]
requires = [
    "setuptools>=42",
    "pandas",
    "wheel"
]
build-backend = "setuptools.build_meta"

but neither worked. Am I declaring pandas at the wrong place? Are there some other files/folder-structure which I should share for solving this problem? Any help is welcome

Asked By: Martin Clever

||

Answers:

Ok, so it did actually work as soon as I uploaded it to the "real" PyPl. I have no clue why it wouldn’t work for Test PyPl, if you do know, feel free to enlighten us in the comments, I’ll update the answer.

Answered By: Martin Clever

Test PyPI is separate from PyPI, and does not have every dependency you try to download, which is why they aren’t found. According to the docs, you can use --extra-index-url to point to PyPI for dependencies.

Example:

python3 -m pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ your-package
Answered By: William Spear
Categories: questions Tags: , , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.