Michael
Michael

Reputation: 1963

Can't install my own PyPi package: requirements can't be satisfied

I am trying to publish a PyPI package. I am testing by first uploading to TestPyPI. My setup.py is fairly simple:

import pathlib
from setuptools import setup, find_packages

# The directory containing this file
HERE = pathlib.Path(__file__).parent

# The text of the README file
README = (HERE / "README.md").read_text()

# This call to setup() does all the work
setup(
    name="my_package_name",
    version="0.0.1",
    description="My first Python package",
    long_description=README,
    long_description_content_type="text/markdown",
    url="https://github.com/my_package_url",
    author="John Smith",
    author_email="[email protected]",
    license="MIT",
    classifiers=[
        "License :: OSI Approved :: MIT License",
        "Programming Language :: Python :: 3",
        "Programming Language :: Python :: 3.7",
    ],
    packages=find_packages(exclude=("test",)),
    include_package_data=True,
    install_requires=[
        "numpy",
        "scipy",
        "pandas",
        "statsmodels",
    ],
)

I am following this tutorial. Basically, once setup.py is prepared, I run

python3 setup.py sdist bdist_wheel

then

twine upload --repository-url https://test.pypi.org/legacy/ dist/*

Finally, to actually test my package installation, I create a new virtual environment and run

pip install -i https://test.pypi.org/simple/ my_package_name

However, I keep getting errors related to pandas and statsmodels requirements not being satisfied:

ERROR: Could not find a version that satisfies the requirement pandas (from my_package_name) (from versions: none)
ERROR: No matching distribution found for pandas (from my_package_name)

Is it because TestPyPI doesn't have those packages (unlike PyPI)? Then how do people normally test end-to-end that their packages can be smoothly installed by other users?

Upvotes: 3

Views: 481

Answers (1)

phd
phd

Reputation: 94397

You can have only one index but you can have as many extra indices as you wish. Add the main PyPI as an extra index:

pip install -i https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ my_package_name

First pip looks into the index and then scan extra indices until it finds the package.

Upvotes: 5

Related Questions