Home > Database > Mysql Tutorial > How to Force Pip to Install a Specific, Non-Latest Package Version?

How to Force Pip to Install a Specific, Non-Latest Package Version?

Barbara Streisand
Release: 2024-12-27 05:50:08
Original
704 people have browsed it

How to Force Pip to Install a Specific, Non-Latest Package Version?

Installing a Specific Package Version with Pip

When attempting to install a specific version of a package using pip, users may encounter challenges when the requested version is not the latest available. This article explores a solution to this issue.

Problem:

A user is attempting to install version 1.2.2 of the MySQL_python package in a fresh virtualenv with the --no-site-packages option. However, despite specifying the version using pip install MySQL_python==1.2.2, the installed package is still shown as MySQL_python-1.2.3-py2.6.egg-info in the site packages.

Solution:

To force pip to install a specific package version, even if it's not the latest, use the --force-reinstall -v options. The --force-reinstall option ensures that the package is reinstalled, even if it's already up-to-date, and the -v option provides verbose output for additional information.

pip install --force-reinstall -v "MySQL_python==1.2.2"
Copy after login

Alternative Option:

In some cases, using the --ignore-installed -v options can be effective. The --ignore-installed option instructs pip to ignore existing installed packages and overwrite them with the specified version.

pip install -Iv MySQL_python==1.2.2
Copy after login

Additional Considerations:

  • Check the pip installation log or use pip install -Iv to verify that the PyPI URL link for the desired version exists and is not 404.
  • If the PyPI link is broken, manually download the package from the source and use pip install -Iv to install it directly.

Conclusion:

By utilizing the --force-reinstall -v or --ignore-installed -v options, users can successfully install specific package versions using pip, even if they are not the latest available.

The above is the detailed content of How to Force Pip to Install a Specific, Non-Latest Package Version?. 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