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:

pip 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
Answer from Mahmoud Abdelkader on Stack Overflow
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:

pip 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:

pip 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:

pip install 'stevedore>=1.3.0,<1.4.0' --force-reinstall
๐ŸŒ
iO Flood
ioflood.com โ€บ blog โ€บ pip-update-package
PIP Update Packages in Python | Practical Commands
August 12, 2024 - Basic Use: The fundamental command to update a Python package using pip is pip install --upgrade package-name. This command tells pip to find the latest version of the specified package and install it, replacing the old version if it exists.
Discussions

linux - How do I update a Python package? - Stack Overflow
The 0.19.1 package has files in ... /usr/lib/pymodules.python2.6). How can I completely uninstall version 0.19.1 from my system before installing 0.20.2? ... Note: Some users may have pip3 installed instead. In that case, use ... Sign up to request clarification or add additional context in comments. ... And if you are using a proxy without authentication: sudo pip install [package] --upgrade --proxy=address:port 2017-01-18T12:20:14.413Z+00:00 ... I came here for this answer. I tried pip update and pip upgrade ... More on stackoverflow.com
๐ŸŒ stackoverflow.com
What's your process for updating python versions/packages while maintaining backwards compatibility?
No one has said unit tests. Unit tests to validate functionality is key to confirm no features you're using changed in any way that affects your application. When you update a package, run your tests make sure everything passes and then do some manual testing too. When you update python do the same A combination of unit tests, reading of release notes, and a quick manual test where you look for any deprecation earnings or unexpected exceptions goes a very long way More on reddit.com
๐ŸŒ r/learnpython
15
14
April 5, 2024
How can I upgrade Python to a specific version? - Stack Overflow
I am currently working on Python 2.6.5 and I would like to upgrade to Python 2.6.6. Is there a way I can do so? More on stackoverflow.com
๐ŸŒ stackoverflow.com
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
๐ŸŒ
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 - Use pip install package==version to install a specific package version. Use pip show and pip index versions to inspect installed and available versions. Manage multiple dependencies with requirements.txt.
๐ŸŒ
It's FOSS
itsfoss.com โ€บ upgrade-pip-packages
How to Upgrade Python Packages with Pip
September 1, 2023 - To list outdated packages of Python, you just have to pair pip command with list option and --outdated flag as shown: ... Once you get the list of the packages that need to be updated, you can be selective as I mentioned earlier, and to update a specific package, youโ€™ll need to follow the given command syntax: ... For example, I want to upgrade the package named anime-api to the most recent version...
๐ŸŒ
Kanaries
docs.kanaries.net โ€บ topics โ€บ Python โ€บ upgrade-py-package
How to Upgrade Python Packages: A Comprehensive Guide โ€“ Kanaries
In this section, we address some commonly raised questions concerning package management. ... Replace 1.2.3 with your desired version. ... Again, replace 1.2.3 with the specific version you want.
๐ŸŒ
Reddit
reddit.com โ€บ r/learnpython โ€บ what's your process for updating python versions/packages while maintaining backwards compatibility?
r/learnpython on Reddit: What's your process for updating python versions/packages while maintaining backwards compatibility?
April 5, 2024 -

Auditors have recently been hounding me to update my Python version from 3.7 since it's fallen out of support and apparently a few exploits exist that are significant enough to raise an eyebrow.

It was easy enough to get python 3.12 installed and I don't have any concern with the changes in regards to alterations to the syntax of basic python, however, when packages come into the picture quite a few of my commonly used packages have also received updates and undergone some form of deprecation that would require some revision.

The easy approach would be just to install the known working versions of the packages but if there are security concerns with python itself I can only imagine that there have to be some lurking in some of these packages that haven't been updated for 5+ years.

In the past I just had a single master venv that was more or less shared across all projects, which I'm aware is bad practice but with 30+ active projects that require more or less the same packages so creating individual virtual environments for all of them would have been a bit of a chore.

My first approach was to create a new master venv with only the new packages but tested it on a few small projects and (as expected) there were immediate conflicts that required some code adjustments.

Obviously I would rather avoid making changes across the whole code base if I can avoid it, so I'm kind of curious if anybody has a better approach. My first thought which seems easiest is just creating a secondary master venv for legacy code with old package versions and use the updated venv for any new code but I'm unsure if that's the "right" way to do things.

Thoughts?

Find elsewhere
๐ŸŒ
PythonHow
pythonhow.com โ€บ how โ€บ install-specific-package-versions-with-pip
Here is how to install specific package versions with pip in Python
You can also use the '~=' operator to specify a range of compatible versions, for example: pip install example-package~=2.0This will install any version of example-package that is compatible with version 2.0. *Please note that the package must be available in the version you are specifying ...
๐ŸŒ
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!# โœ… install a specific version of `pip` pip install --upgrade pip==8.1.2 # โœ… install a specific version of a package using `pip` pip install requests==2.28.0 --ignore-installed # โœ… upgrade pip to the latest version pip install --upgrade ...
๐ŸŒ
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 - Learn how to install and manage specific package versions of Python using pip and apt. This beginner-friendly guide covers package version control, downgrading, and efficient installation across Windows and Linux.
Top answer
1 of 7
23

In almost all cases, this is a bad idea. Changing the system Python can and quite often will break some other packages depending on the previous environment or version. Upgrading from Python 3.10 to 3.13 means quite a few things have been changed and/or removed, making such problems likely.


So, how can you use a more modern version of Python?

One way ist the way you have already gone, installing it and accessing it via python3.13.

Another way is using the deadsnakes PPA, see e.g. this answer by Hannu (but refrain from overriding your system default).


And then there are multiple ways to get access to a specific Python version within a specific project, here is a small selection:

  1. Pyenv is the classic solution for this. It allows you to download and install basically any Python version (even alpha and beta) and activate them dynamically or use them as the base for a virtual environment.
  2. UV, a upcoming Python dependency manager, can manage Python versions as well. You just have to specify the desired Python version in a .python_version file in your project root directory.
  3. Conda, another dependency manager, but not limited to Python, can also manage multiple Python versions.
2 of 7
9

A simple "clean" way to install a more recent Python3 than present in Ubuntu is the deadsnakes ppa:

Howto set the default version:
https://www.debugpoint.com/install-python-3-12-ubuntu/
... at "Use Python 3.12 as the default Python3"

The basics for installation:

sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt update 
sudo apt install python3.12

https://launchpad.net/~deadsnakes/+archive/ubuntu/ppa
The ppa gets updated, so a more recent one may well be present;
also ALWAYS verify the correctness of what is stated above.

๐ŸŒ
Sentry
sentry.io โ€บ sentry answers โ€บ python โ€บ upgrade specific `pip` packages in python
Upgrade specific `pip` packages in Python | Sentry
January 30, 2023 - How can I upgrade specific Python packages using pip? To upgrade an installed package, call pip install with the --upgrade flag. ... This will upgrade the package to the latest available versions.
๐ŸŒ
Saturn Cloud
saturncloud.io โ€บ blog โ€บ updating-python-to-a-specific-version-using-conda-a-guide
Updating Python to a Specific Version Using Conda: A Comprehensive Guide | Saturn Cloud Blog
May 1, 2026 - In this blog, we'll explore how to update Python to a specific version using Conda, a versatile tool for managing packages and environments. This guide is essential for those working on diverse projects with specific Python version requirements in data science, machine learning, and web development.
๐ŸŒ
Better Stack
betterstack.com โ€บ community โ€บ questions โ€บ installing-specific-package-version-with-pip
Installing specific package version with pip | Better Stack Community
February 3, 2023 - To install a specific version of a package with pip, you can use the == operator followed by the desired version number. For example: ... This will install version 1.0.4 of the package.
๐ŸŒ
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 - There are 2 must-know ways to install a specific version of a Python package. The first one requires two commands โ€“ the first one for uninstalling the current version, and the second for installing the version you want.
๐ŸŒ
Python
docs.python.org โ€บ 3 โ€บ installing โ€บ index.html
Installing Python modules โ€” Python 3.14.6 documentation
python -m pip install SomePackage==1.0.4 # specific version python -m pip install "SomePackage>=1.0.4" # minimum version ยท Normally, if a suitable module is already installed, attempting to install it again will have no effect.
๐ŸŒ
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 - In the next section, we will look at specifying the version of multiple Python packages by creating a .txt file. ... This post is structured as follows to guide you through the process of using pip to install a specific version of a package. In the first section, we will explore the rationale behind using pip to downgrade a package and highlight why we might want to have an older version of a package in specific scenarios.
๐ŸŒ
JetBrains
jetbrains.com โ€บ help โ€บ pycharm โ€บ installing-uninstalling-and-upgrading-packages.html
Install, uninstall, and upgrade packages | PyCharm Documentation
Click the Add Package link on the Python Packages toolbar and select From Disk. Specify a path to the package directory or an archive (zip or whl). Select Install as editable (-e) if you want to install the package in the editable mode (for ...