Alternatively, since pip itself is written in python, you can just call it with the python version you want to install the package for:

Copypython2.7 -m pip install foo
Answer from Turion on Stack Overflow
🌐
Built In
builtin.com › articles › pip-install-specific-version
Pip Install a Specific Version: A Guide | Built In
You can install a specific version of a Python package using Pip by running the pip install <package_name>==<version> command. For example, to install version 1.3.4 of Pandas, execute the pip install pandas==1.3.4 command from the terminal.
Discussions

python - Installing specific package version with pip - Stack Overflow
Copypip uninstall MySQL_python pip install -Iv http://sourceforge.net/projects/mysql-python/files/mysql-python/1.2.2/MySQL-python-1.2.2.tar.gz/download ... Sign up to request clarification or add additional context in comments. ... There should be no problem with having multiple versions though, that's the point of creating new folders for every version and using .pth files. 2011-03-07T23:26:11.437Z+00:00 ... Curious why you use ... More on stackoverflow.com
🌐 stackoverflow.com
How do I choose what python version pip installs packages to.
You should work the other way around, as pip is a component of a python environment. It's not a standalone installer tool. Meaning the pip you launch by default is one of the many environments and thus probably not the one your want. Instead you should first activate your specific environment, then run pip from it, eg path/to/venv> activate your venv path/to/venv> python -m pip install etc More on reddit.com
🌐 r/learnpython
8
7
May 31, 2023
How to use pip install to install a "specific version" of a library ?
Put that into a requirements.txt file - either manually or by doing pip freeze > requirements.txt - then in your other environment do pip install -r requirements.txt to install exactly the versions listed there. More on reddit.com
🌐 r/learnpython
2
1
February 19, 2022
Are python packages tied to a specific python version?
Yes, python packages are installed in site-packages directory, which is tied to a specific python installation. If you want to install packages for a specific pyhon installation use python3.9 -m pip install requests, or even better setup a venv for each project. More on reddit.com
🌐 r/learnpython
10
2
November 1, 2022
🌐
PythonHow
pythonhow.com › how › install-specific-package-versions-with-pip
Here is how to install specific package versions with pip in Python
To install a specific version of a package using pip in python, you can use the package name followed by the version number you want to install and use the == operator.
🌐
Sentry
sentry.io › sentry answers › python › install a specific version of a python package using pip
Install a specific version of a Python package using PIP | Sentry
We can install an older version of a specific package by using the following syntax in our PIP command: ... The == syntax allows us to specify a version number.
🌐
Python
docs.python.org › 3 › installing › index.html
Installing Python modules — Python 3.14.6 documentation
On Linux, macOS, and other POSIX systems, use the versioned Python commands in combination with the -m switch to run the appropriate copy of pip: python3 -m pip install SomePackage # default Python 3 python3.14 -m pip install SomePackage # ...
Top answer
1 of 12
1612

TL;DR:

Update as of 2022-12-28:

pip install --force-reinstall -v

For example: pip install --force-reinstall -v "MySQL_python==1.2.2"

What these options mean:

  • --force-reinstall is an option to reinstall all packages even if they are already up-to-date.
  • -v is for verbose. You can combine for even more verbosity (i.e. -vv) up to 3 times (e.g. --force-reinstall -vvv).

Thanks to @Peter for highlighting this (and it seems that the context of the question has broadened given the time when the question was first asked!), the documentation for Python discusses a caveat with using -I, in that it can break your installation if it was installed with a different package manager or if if your package is/was a different version.


Original answer:

  • pip install -Iv (i.e. pip install -Iv MySQL_python==1.2.2)

What these options mean:

  • -I stands for --ignore-installed which will ignore the installed packages, overwriting them.
  • -v is for verbose. You can combine for even more verbosity (i.e. -vv) up to 3 times (e.g. -Ivvv).

For more information, see pip install --help

First, I see two issues with what you're trying to do. Since you already have an installed version, you should either uninstall the current existing driver or use pip install -I MySQL_python==1.2.2

However, you'll soon find out that this doesn't work. If you look at pip's installation log, or if you do a pip install -Iv MySQL_python==1.2.2 you'll find that the PyPI URL link does not work for MySQL_python v1.2.2. You can verify this here: http://pypi.python.org/pypi/MySQL-python/1.2.2

The download link 404s and the fallback URL links are re-directing infinitely due to sourceforge.net's recent upgrade and PyPI's stale URL.

So to properly install the driver, you can follow these steps:

Copypip uninstall MySQL_python
pip install -Iv http://sourceforge.net/projects/mysql-python/files/mysql-python/1.2.2/MySQL-python-1.2.2.tar.gz/download
2 of 12
769

You can even use a version range with pip install command. Something like this:

Copypip install 'stevedore>=1.3.0,<1.4.0'

And if the package is already installed and you want to downgrade it add --force-reinstall like this:

Copypip install 'stevedore>=1.3.0,<1.4.0' --force-reinstall
🌐
Towards Data Science
towardsdatascience.com › home › latest › pip install specific version – how to install a specific python package version with pip
Pip Install Specific Version - How to Install a Specific Python Package Version with Pip | Towards Data Science
January 27, 2025 - The superior approach to the one from the previous section is to install a specific version of a Python package with a single shell command. You can do so by appending the --ignore-installed flag when installing a specific version of the package.
Find elsewhere
🌐
Bobby Hadz
bobbyhadz.com › blog › python-pip-install-specific-package-version
Pip install a specific version of a Python package | bobbyhadz
April 10, 2024 - Copied!pip install --upgrade pip==8.1.2 ... pip==8.1.2 · If you need to check all of the available versions of pip, use the pip install pip== command....
🌐
Python Packaging
packaging.python.org › tutorials › installing-packages
Installing Packages - Python Packaging User Guide
To install the latest version of “SomeProject”: ... In this case, this means to install any version “==1.4.*” version that’s also “>=1.4.2”. pip can install from either Source Distributions (sdist) or Wheels, but if both are present on PyPI, pip will prefer a compatible wheel.
🌐
InfinitySoftHint
infinitysofthint.com › home › python › a detailed guide about installing specific package versions with pip and python?
Installing Specific Package Versions with Pip and Python
May 20, 2025 - You can set a specific version to install the command to specify which pip version you need to install. Before downgrading, check your current pip version: ... The specified version of pip will become the active version after this command executes.
🌐
Syntx Scenarios
syntaxscenarios.com › home › python › pip install specific version (step-by-step guide)
Pip Install Specific Version (Step-by-Step Guide)
September 15, 2025 - It’s best practice to manage packages inside a virtual environment so dependencies don’t conflict across projects: python -m venv myenv source myenv/bin/activate # macOS/Linux myenv\Scripts\activate # Windows pip install pandas==1.3.4
🌐
iO Flood
ioflood.com › blog › pip-install-specific-version
Using PIP to Install a Specific Version of a Python Package
March 27, 2024 - To install a specific version of a package using pip, use the syntax pip install package==version. For example, to install version 1.0.0 of a package named ‘sample’, use pip install sample==1.0.0.
🌐
Seaborn Line Plots
marsja.se › home › programming › python › pip install specific version of a python package: 2 steps
Pip Install Specific Version of a Python Package: 2 Steps
September 22, 2024 - Before getting into more details, ... To install a specific version of a Python package, you can use pip: pip install YourPackage==YourVersion....
🌐
Tutorial Reference
tutorialreference.com › python › examples › faq › python-how-to-pip-install-specific-package-version
How to Pip Install Specific Version of a Package (and Pip itself) in Python | Tutorial Reference
Installing specific versions of Python packages is crucial for stable and reproducible development environments. Use pip install <package-name>==<version> to install an exact version.
🌐
Pierian Training
pieriantraining.com › home › tutorial: how to pip install a specific version of a python library
Tutorial: How to Pip Install a Specific Version of a Python Library - Pierian Training
April 27, 2023 - Once you have Python installed, pip can be installed using the command line interface by typing “pip install pip”. Pip comes with several useful features that make it a great tool for managing package dependencies in your projects.
🌐
Squash
squash.io › how-to-install-specific-package-version-with-pip-in-python
How to Install Specific Package Versions With Pip in Python
November 2, 2023 - Here's the command to install a specific version of a package using pip: ... Replace package_name with the name of the package you want to install and desired_version with the version number you want to install.
🌐
Unixmen
unixmen.com › home › linux howto's › pip: install specific version of a python package instructions
Pip: Install Specific Version of a Python Package Instructions | Unixmen
In pip, installing a specific version is easy and it has just got easier with Unixmen guiding you through the process. Pip allows you to control the exact Python package version used in your projects.
🌐
Reddit
reddit.com › r/learnpython › how to use pip install to install a "specific version" of a library ?
r/learnpython on Reddit: How to use pip install to install a "specific version" of a library ?
February 19, 2022 -

How do I specify to pip installer that I want a specific version of a library. And how do I rollback (uninstall a library if I make a mistake)?

I am using Python 3.9.9 in my dev environment and want this same version in my Linux Buildozer.

Here's what I have installed in my dev environment, and want it mirrored in my Buildozer environment:

Python 3.9.9
 certifi==2021.10.8
 charset-normalizer==2.0.7
 docutils==0.18
 idna==3.3
 Kivy==2.0.0
 kivy-deps.angle==0.3.0
 kivy-deps.glew==0.3.0
 kivy-deps.sdl2==0.3.1
 Kivy-Garden==0.1.4
 kivymd @ https://github.com/kivymd/KivyMD/archive/master.zip
 Pillow==8.4.0
 plyer==2.0.0
 Pygments==2.10.0
 pypiwin32==223
 python-percentage==1.0.0
 pywin32==302
 requests==2.26.0
 urllib3==1.26.7 

(I am installing a virtual machine on my PC, and Buildozer under Linux in that.)