Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Installing specific package versions with pip

I am trying to install version 1.2.2 of MySQL_python, using a fresh virtualenv created with the --no-site-packages option. The current version shown in PyPi is 1.2.3. Is there a way to install the older version? I have tried:

pip install MySQL_python==1.2.2 

However, when installed, it still shows MySQL_python-1.2.3-py2.6.egg-info in the site packages. Is this a problem specific to this package, or am I doing something wrong?

like image 835
Joe Avatar asked Mar 07 '11 22:03

Joe


People also ask

How do I install a specific version of a package?

Use npm list [package-name] to know the specific latest version of an installed package. Use npm install [package-name]@[version-number] to install an older version of a package. Prefix a version number with a caret (^) or a tilde (~) to specify to install the latest minor or patch version, respectively.

How do I apply a specific version of a package in Python?

How do I Install a Specific Version of a Python Package? To install a specific version of a Python package you can use pip: pip install YourPackage==YourVersion . For example, if you want to install an older version of Pandas you can do as follows: pip install pandas==1.1.


2 Answers

TL;DR:

  • 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 
like image 135
Mahmoud Abdelkader Avatar answered Sep 29 '22 12:09

Mahmoud Abdelkader


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 
like image 25
user1978556 Avatar answered Sep 29 '22 11:09

user1978556