PyPI Simple Repository API Client
pypi-simple is a client library for the Python Simple Repository API, as specified in PEP 503 and updated by various other PEPs (592, 629, 658, 691, 700, 708, 714, 740, 792). It allows users to query PyPI and other pip-compatible repositories for available projects and their package files, download packages, and inspect their metadata. The current version is 1.8.0. While no explicit release cadence is stated, the project maintains regular updates, with version 1.8.0 released on September 3, 2025.
Common errors
-
ImportError: cannot import name 'PyPISimple' from 'pypi_simple'
cause Typo in the import statement or trying to import from an incorrect module.fixEnsure the import path is exactly `from pypi_simple import PyPISimple`. -
AttributeError: 'NoneType' object has no attribute 'packages'
cause The `get_project_page()` method returned `None`, indicating that the project name was not found or there was an issue fetching the page.fixAlways check if the result of `get_project_page()` is `None` before attempting to access its attributes (e.g., `if project_page and project_page.packages:`). -
PyPISimple.exceptions.DigestMismatchError: Digest mismatch for ...
cause The downloaded package file's digest (e.g., SHA256) does not match the one advertised by the repository, indicating possible corruption or tampering.fixThis often points to a problem with the repository or download. You can try downloading again. If it persists, report it to the package maintainers or the repository. The exception object itself might contain `url` fields for more details.
Warnings
- deprecated The `DistributionPackage.provenance_sha256` attribute is deprecated and will always be `None`.
- deprecated The `verify` argument in `PyPISimple.get_provenance()` is deprecated, and the method no longer verifies the provenance's digest.
- breaking Support for Python 3.7 was dropped in version 1.6.0.
- gotcha Calling `PyPISimple.get_index_page()` (which returns a list of all projects) can be very slow due to the size of PyPI's index. PyPI's top-level simple HTML page is also cached for 24 hours.
Install
-
pip install pypi-simple -
pip install "pypi-simple[tqdm]"
Imports
- PyPISimple
from pypi_simple import PyPISimple
- tqdm_progress_factory
from pypi_simple import PyPISimple, tqdm_progress_factory
Quickstart
from pypi_simple import PyPISimple
# Example 1: Get information about a package
with PyPISimple() as client:
requests_page = client.get_project_page('requests')
if requests_page and requests_page.packages:
pkg = requests_page.packages[0]
print(f"Latest 'requests' package: {pkg.filename} (version {pkg.version})")
print(f"Download URL: {pkg.url}")
# Example 2: List all project names (caution: this can be slow and large)
# try:
# with PyPISimple() as client:
# # PyPI's top-level simple HTML page is cached for 24 hours.
# # Use stream_project_names() for potentially faster, memory-efficient retrieval.
# all_projects = list(client.stream_project_names())
# print(f"Found {len(all_projects)} projects.")
# except Exception as e:
# print(f"Error listing projects: {e}")