Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.

To install an exact Python package version, run python -m pip install "PackageName==1.2.3", replacing the package name and version with the ones you need. On Windows, you can use py -m pip install "PackageName==1.2.3". The == operator pins the named package; its dependencies may still be resolved separately.

Install it in the right Python environment

Using python -m pip ties pip to the Python interpreter named by python. A bare pip install can point to a different Python installation, so the package may not be available to the program you run later. On Windows, py -m pip uses the Python launcher; specify a version when you have several installed.

# macOS, Linux, or a shell where python is the intended interpreter
python -m pip install "requests==2.31.0"

# Windows
py -m pip install "requests==2.31.0"

# Select Python 3.12 explicitly on Windows
py -3.12 -m pip install "requests==2.31.0"

Check which interpreter and pip are in use:

python --version
python -c "import sys; print(sys.executable)"
python -m pip --version

On Windows, replace python with py in those commands, or use py -3.12 to select a particular version. If you need pip to manage a separately selected interpreter or environment, see pip’s Python option.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use a virtual environment for a project

A virtual environment keeps project packages separate from other projects and the system Python. From your project directory, create one:

#1 Best Overall
Python 25 ft. No Spill Clean & Fill & Python Porter Package
  • The Python 25 ft. No Spill Clean & Fill works with your faucet to siphon water from your tank directly into the sink, making water changes a breeze
  • The Python Porter is a must have accessory for anyone who is using a No Spill Clean & Fill. When storing or transporting your No Spill Clean & Fill it will keep the tubing coiled properly.
python -m venv .venv

Activate it, then install the pinned package:

# macOS or Linux
source .venv/bin/activate
python -m pip install "PackageName==1.2.3"

# Windows Command Prompt
.venvScriptsactivate
py -m pip install "PackageName==1.2.3"

# Windows PowerShell
.venvScriptsActivate.ps1
py -m pip install "PackageName==1.2.3"

You can skip activation by calling the environment’s Python directly:

# macOS or Linux
.venv/bin/python -m pip install "PackageName==1.2.3"

# Windows
.venvScriptspython.exe -m pip install "PackageName==1.2.3"

If PowerShell blocks the activation script, that is an execution-policy issue, not a pip installation error. You can use the direct interpreter command above, or—if appropriate for your machine—allow locally created scripts for your user with Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser. Python’s venv documentation covers creating and activating environments. Virtual environments are generally disposable; do not commit the .venv directory to source control.

Find a version and check compatibility

Ask pip which releases it can see on the configured package index:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
python -m pip index versions PackageName

For example, use python -m pip index versions requests. To include pre-releases in the results, add --pre:

python -m pip index versions PackageName --pre

A listed release is not necessarily installable in your environment. It must also support your Python version and have a compatible distribution for your operating system, architecture, Python implementation, and ABI. A private or custom package index may show a different set of releases. See pip’s index command and install command documentation for compatibility and index options.

Choose the right version specifier

For a single exact version, use ==. Other specifiers describe ranges or release series, not one fixed release:

Goal Example Meaning
Exact version "package==1.2.3" Request version 1.2.3.
Minimum version "package>=1.2.3" Request 1.2.3 or a newer version that satisfies the other requirements.
Bounded range "package>=1.2.3,<2.0" Allow versions from 1.2.3 up to, but not including, 2.0.
Compatible release range "package~=1.2.3" Allow compatible releases under PEP 440’s compatible-release rules.
Release series "package==1.2.*" Match releases in the 1.2 series; this is not a single-version pin.

Quotes are good portable practice, particularly for range operators such as < and >, which shells may interpret. Read pip’s requirement specifier reference for the full syntax.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Install a pre-release deliberately

If you know the exact release candidate or beta you need, specify it directly, such as python -m pip install "package==2.0.0rc1". To let pip consider pre-releases while resolving an unpinned requirement, use --pre:

python -m pip install --pre package

--pre broadens the candidates pip may choose; it does not mean “install this particular pre-release.” An exact pre-release specifier is clearer when you already know the desired version.

Downgrade or reinstall a package

To move from an installed release to an older one, request the older version with the same exact-version command:

python -m pip install "PackageName==1.2.3"

Pip can replace an installed version that does not satisfy the request, provided it can resolve the package’s requirements in the environment. You do not normally need --force-reinstall just to downgrade. Use it when you specifically want to reinstall even though that version is already installed:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
python -m pip install --force-reinstall "PackageName==1.2.3"

If you need to bypass pip’s cached files while troubleshooting, add --no-cache-dir. It is not a routine requirement:

python -m pip install --force-reinstall --no-cache-dir "PackageName==1.2.3"

Verify the installation

Check the package metadata with pip:

python -m pip show PackageName

Look for the Version field. Or query it from Python using the package’s distribution name:

python -c "import importlib.metadata as m; print(m.version('beautifulsoup4'))"

The distribution name used by pip can differ from the name imported in Python: for example, the distribution beautifulsoup4 is imported as bs4. Use the distribution name with importlib.metadata. Then check whether installed packages’ declared dependencies are consistent:

python -m pip check

No broken requirements found. means pip found no dependency metadata conflicts. It does not prove the application works at runtime. See the pip show and pip check references.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Save the pin for future installs

For a project that needs one package at a fixed version, add a line to requirements.txt:

requests==2.31.0

Install the listed requirements with:

python -m pip install -r requirements.txt

A single pin does not pin that package’s dependencies. To record all packages currently installed in the environment, generate a snapshot:

python -m pip freeze > requirements.txt

Recreate it with python -m pip install -r requirements.txt. A frozen list improves repeatability, but results may still differ across Python versions, platforms, and package indexes or if an artifact is no longer available. Requirements files are pip installation inputs and can contain more than exact pins; see the requirements file format and pip’s user guide.

A constraints file is different: it restricts which version pip can select for a package that is otherwise required; it does not cause that package to be installed. For example, to limit a transitive dependency while installing another package:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
# constraints.txt
urllib3<2

# Install a package that requires urllib3
python -m pip install -c constraints.txt package-that-uses-urllib3

Use constraints when you need to control a dependency without listing it as a direct install request. The pip user guide explains this distinction.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshoot common failures

“No matching distribution found”

This means pip did not find a candidate it could install from the configured sources. Check for a misspelled distribution name or version, then inspect the available releases and the environment:

python -m pip index versions PackageName
python --version
python -m pip --version
python -m pip config list

The release may not exist on that index, may be a pre-release, or may have no compatible distribution for your Python or platform. If the package is hosted on a company index, confirm that pip is configured to use the intended source. Do not casually add a public index alongside a private one: public and private indexes can contain projects with the same name, creating a dependency-confusion risk. See pip’s installation documentation for index behavior.

The release requires a different Python

Choose a Python version supported by the requested release, create a virtual environment with that interpreter, and install into it. Alternatively, choose a package release compatible with your current Python. Do not treat --ignore-requires-python as a normal fix: bypassing compatibility metadata can leave you with code that fails to build or run.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Dependency conflict

Pinning the named package does not pin all of its dependencies. If requested packages require incompatible versions of a shared dependency, pip’s resolver may report a conflict. Review the conflict details, select compatible top-level versions, or use a justified constraint for the transitive dependency. A clean virtual environment can help isolate the problem. Avoid using --no-deps as a general way around resolver errors; it skips dependency installation and can leave the environment incomplete. If dependencies are managed separately and you intentionally use it, check the result with python -m pip check. See pip’s dependency resolution guide.

A source build fails or no wheel is available

Pip can install a compatible wheel when one is available; otherwise it may need to build from source, which can require build tools or system libraries. To require a wheel and fail rather than build from source, try:

python -m pip install --only-binary=:all: "PackageName==1.2.3"

This helps diagnose whether a compatible wheel exists; it will not create one. --prefer-binary prefers wheels where possible, while --no-binary=:all: forces source distributions and is generally for specialized build or testing needs. See pip’s wheel guidance and build-system reference.

Other installation sources

If you already have the exact wheel file, install it by path:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
python -m pip install ./dist/PackageName-1.2.3-py3-none-any.whl

Wheel filenames encode compatibility information; a wheel built for a different Python or platform may be rejected. You can also use a direct URL or a version-control tag when you trust the source:

python -m pip install "PackageName @ https://example.com/PackageName-1.2.3.tar.gz"
python -m pip install "PackageName @ git+https://github.com/example/[email protected]"

These install from the specified artifact or repository reference rather than selecting a normal package-index release. A tag or URL is only as trustworthy and reproducible as its source; consult pip’s requirement specifier documentation before using direct references.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.