Home > Backend Development > Python Tutorial > Why Can't Pip Install My Package from TestPyPI, Even Though It Works from PyPI?

Why Can't Pip Install My Package from TestPyPI, Even Though It Works from PyPI?

Linda Hamilton
Release: 2024-12-03 18:48:12
Original
611 people have browsed it

Why Can't Pip Install My Package from TestPyPI, Even Though It Works from PyPI?

Pip install from pypi Works, but Not from Testpypi (Cannot Find Requirements)

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
Copy after login

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
Copy after login

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!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template