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
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.
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
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
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.
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