Installing Specific Package Version With Pip

Installing specific package version with pip

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

How to install a specific version of a package with pip?

Use ==:

pip install django_modeltranslation==0.4.0-beta2

Install a module using pip for specific python version

Use a version of pip installed against the Python instance you want to install new packages to.

In many distributions, there may be separate python2.6-pip and python2.7-pip packages, invoked with binary names such as pip-2.6 and pip-2.7. If pip is not packaged in your distribution for the desired target, you might look for a setuptools or easyinstall package, or use virtualenv (which will always include pip in a generated environment).

pip's website includes installation instructions, if you can't find anything within your distribution.

How to pip install a package with min and max version range?

You can do:

$ pip install "package>=0.2,<0.3"

And pip will look for the best match, assuming the version is at least 0.2, and less than 0.3.

This also applies to pip requirements files. See the full details on version specifiers in PEP 440.

Unable to downgrade version of Python package by `pip install -I`

Use --force-reinstall instead of -I, --ignore-installed.

-I can break existing installs, according to the docs:

-I, --ignore-installed Ignore the installed packages, overwriting them. This can break your system if the existing package is of a different version or was installed with a different package manager!

If you want to install a version older than what you currently have installed, --force-reinsall is a better fit:

--force-reinstall Reinstall all packages even if they are already up-to-date.

A demonstration of --force-reinstall in action:

$ pip install arrow==0.17.0
Collecting arrow==0.17.0
<... snip ...>
Successfully installed arrow-0.17.0

$ pip install --force-reinstall arrow==0.13.2
Collecting arrow==0.13.2
<... snip ...>
Attempting uninstall: arrow
Found existing installation: arrow 0.17.0
Uninstalling arrow-0.17.0:
Successfully uninstalled arrow-0.17.0
Successfully installed arrow-0.13.2 python-dateutil-2.8.1 six-1.15.0

$ pip freeze | grep arrow
arrow==0.13.2


Related Topics



Leave a reply



Submit