When trying to install a custom Python package from the testpypi server, you may encounter an error indicating that your required dependencies cannot be found. This occurs despite successfully uploading the package to testpypi.
To resolve this issue, modify your setup.py file to include the following:
pip install --extra-index-url https://testpypi.python.org/pypi poirot
Explanation:
The --extra-index-url argument specifies a supplemental package repository that pip should consult when searching for dependencies. When using --extra-index-url, you must provide the URL of your package on the testpypi server. In this case, the URL is https://testpypi.python.org/pypi/poirot (where "poirot" is the name of your package).
This allows pip to find your package on the testpypi server while still searching for its dependencies on the regular PyPI server.
Note:
Recent updates to PyPI recommend using the following command instead:
python -m pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple poirot
This command explicitly specifies the index URLs for both your package and its dependencies.
The above is the detailed content of Why Can't Pip Install My Package from TestPyPI, Even Though It Works from PyPI?. For more information, please follow other related articles on the PHP Chinese website!