Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dealing with multiple Python versions and PIP?

Tags:

python

pip

Is there any way to make pip play well with multiple versions of Python? For example, I want to use pip to explicitly install things to either my site 2.5 installation or my site 2.6 installation.

For example, with easy_install, I use easy_install-2.{5,6}.

And, yes — I know about virtualenv, and no — it's not a solution to this particular problem.

like image 331
David Wolever Avatar asked May 11 '10 16:05

David Wolever


People also ask

How do you pip install for a specific version of 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. 3 .

Which Python version is pip using?

Key terms. pip is the preferred installer program. Starting with Python 3.4, it is included by default with the Python binary installers. A virtual environment is a semi-isolated Python environment that allows packages to be installed for use by a particular application, rather than being installed system wide.

What happens if I have 2 versions of Python?

There's nothing wrong with having two versions of python installed, and it's actually quite common to do so. Usually, one would install them with different names ( python vs python3 , for example) to avoid confusion though.


1 Answers

The current recommendation is to use python -m pip, where python is the version of Python you would like to use. This is the recommendation because it works across all versions of Python, and in all forms of virtualenv. For example:

# The system default python: $ python -m pip install fish  # A virtualenv's python: $ .env/bin/python -m pip install fish  # A specific version of python: $ python-3.6 -m pip install fish 

Previous answer, left for posterity:

Since version 0.8, Pip supports pip-{version}. You can use it the same as easy_install-{version}:

$ pip-2.5 install myfoopackage $ pip-2.6 install otherpackage $ pip-2.7 install mybarpackage 

EDIT: pip changed its schema to use pipVERSION instead of pip-VERSION in version 1.5. You should use the following if you have pip >= 1.5:

$ pip2.6 install otherpackage $ pip2.7 install mybarpackage 

Check https://github.com/pypa/pip/pull/1053 for more details


References:

  • https://github.com/pypa/pip/issues/200
  • http://www.pip-installer.org/docs/pip/en/0.8.3/news.html#id4
    https://pip.pypa.io/en/stable/news/#v0-8 or
    https://web.archive.org/web/20140310013920/http://www.pip-installer.org:80/docs/pip/en/0.8.3/news.html#id4
like image 52
Hugo Tavares Avatar answered Sep 30 '22 20:09

Hugo Tavares