Skip to main content

pip-mark-installed

A utility tool to mark packages as installed for pip or uv without actually installing them.

Description

pip-mark-installed creates the necessary metadata files to make pip believe that a package is installed, without actually installing any of the package code. This is particularly useful for resolving conflicts between different package variants that share the same namespace (e.g. GPU vs CPU, GUI vs headless variants) or when you want to prevent pip from installing certain packages that you have already managed through other means.

Installation

Grab the pip-mark-installed.py script or install it via pip:

pip install pip-mark-installed

Usage

pip-mark-installed PACKAGE_SPEC [PACKAGE_SPEC ...]

Where PACKAGE_SPEC can be either:

  • PACKAGE_NAME (uses a default version of 9999.99.99)
  • PACKAGE_NAME==VERSION

Examples

Mark a package as installed:

pip-mark-installed opencv-python

Mark multiple packages with specific versions:

pip-mark-installed opencv-python==4.5.1 opencv-contrib-python==4.5.1

Specify a custom site-packages directory:

pip-mark-installed --site-packages /path/to/site-packages some-package

Common Use Cases

This tool helps address situations where pip's dependency resolution doesn't behave as desired:

  1. Conflicting Package Variants: When multiple packages offer the same functionality but under identical import names, conflicts can arise. A common example is the various OpenCV packages (e.g., opencv-python, opencv-contrib-python, opencv-python-headless). These all install to the cv2 namespace. You might want the opencv-contrib-python version, but pip might try to install opencv-python due to a dependency in another package. pip-mark-installed allows you to install your preferred version and then "trick" pip into thinking the others are already present, preventing unwanted installations.

    # Install the variant you actually want:
    pip install opencv-contrib-python
    
    # Mark conflicting variants as "installed" to prevent pip from installing them:
    pip-mark-installed opencv-python opencv-python-headless opencv-python-headless
    
  2. Optional or broken dependencies: Sometimes, a package might list an optional dependency that you don't want installed, or a dependency known to cause issues in your specific environment. For instance, a package might list PyQt5 as a dependency, but you want to use PySide6. If these are not strictly necessary, or if you've already managed them outside of pip, you can use pip-mark-installed to satisfy the dependency check without actually installing the packages.

    # Mark PyQt5 as installed, to prevent a dependency from installing them.
    pip-mark-installed PyQt5
    
  3. System-level installations: When a package exists at system level but you want to prevent pip from installing conflicting versions in your environment.

How It Works

The script creates the necessary .dist-info directory structure and metadata files that pip uses to determine if a package is installed.

License

MIT

Metadata

Release files for pip-mark-installed 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pip-mark-installed 1.0.0
File Size Uploaded Provenance Actions
pip_mark_installed-1.0.0.tar.gz 5.6 kB Without provenance Details for pip_mark_installed-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pip-mark-installed 1.0.0
File Interpreter ABI Platform Actions
pip_mark_installed-1.0.0-py2.py3-none-any.whl Python 2, Python 3 none any Details for pip_mark_installed-1.0.0-py2.py3-none-any.whl

Total release size: 11.2 kB

Release files / pip_mark_installed-1.0.0.tar.gz

Download URL pip_mark_installed-1.0.0.tar.gz
Size 5.6 kB
Tags Source
SHA-256 checksum
How to use checksums
43c9e023fd906944a7f7b00e2de0b53a4d02cb46aa84b62180d05c5fa7469c5c
BLAKE2b-256 checksum
How to use checksums
feb434102d229a0d0f73585b8acfd0f90c63a7c0a86b3a9059535c1331950e6b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-httpx/0.28.1

Release files / pip_mark_installed-1.0.0-py2.py3-none-any.whl

Download URL pip_mark_installed-1.0.0-py2.py3-none-any.whl
Size 5.7 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
d56466d48c64085750f4b402affe1619accff2042224feb61f918fefb27808c6
BLAKE2b-256 checksum
How to use checksums
30186870faa11452da3709595351daf30af985a99073e31acf6e2db00e3e239e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-httpx/0.28.1

Security for pip-mark-installed 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page