Search code examples
pythonpandaspippackagesetup.py

ModuleNotFoundError despite declairing install_requires in setup.py


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


Solution

  • 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