How to use pip with Python 3.x alongside Python 2.x
The approach you should take is to install pip
for Python 3.2.
You do this in the following way:
$ curl -O https://bootstrap.pypa.io/get-pip.py
$ sudo python3.2 get-pip.py
Then, you can install things for Python 3.2 with pip-3.2
, and install things for Python 2-7 with pip-2.7
. The pip
command will end up pointing to one of these, but I'm not sure which, so you will have to check.
Can pip (python2) and pip3 (python3) coexist?
Every Python should have own pip
because every Python may use different version of the same module and every Python installs modules in different folder.
You can use Python2
to reinstall module pip
for Python2
and it should create file with correct name pip
python -m pip install -U --force pip
You should also have pip
, pip2
, pip2.7
, pip3
, pip3.5
.
You can even have pip3.6
, pip3.7
at the same time.
If you write in console pip
and press tab
and it should show you all programs which start with word pip
You can find full path for pip
with
which pip
and you can open it in text editor to see if it is python's script.
Different pip
have different first line - ie. #!/usr/bin/python
or #!/usr/bin/python3.5
.
Rest code should be the same for all versions.
Dealing with multiple Python versions and PIP?
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
Using pip version with Python 3.x alongside Python 2.x on Windows
You will want to make sure you have the correct Anaconda environment activated, which it looks like you have in this case.
conda env list # Display the list of conda environments
In the Windows Command Prompt you should just need to use:
activate py35 # Or whatever your Python 3.5 environment is called. (Mine is root)
pip install pymssql
Instead of pip-3.5
.
To install it in another environment (mine is called py27):
activate py27
pip install pymssql
I successfully used this command in both my Python 2.7 and 3.5 Anaconda environments.
To go back to your primary environment (root), just type activate
without an environment name after it
Using pip on Windows installed with both python 2.7 and 3.5
You will have to use the absolute path of pip
.
E.g: if I installed python 3 to C:\python35
, I would use:C:\> python35\Scripts\pip.exe install packagename
Or if you're on linux, use pip3 install packagename
If you don't specify a full path, it will use whichever pip
is in your path
.
Pip for Python 3.8
Install pip the official way:
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python3.8 get-pip.py
made 3.8 my default Python version
It depends on how you did that, but it might break something in your OS. For example some packages on Ubuntu 18.04 might depend on python
being python2.7
or python3
being python3.6
with some pip packages preinstalled.
Related Topics
How to Increase the Cell Width of the Jupyter/Ipython Notebook in My Browser
Generate a Random Date Between Two Other Dates
Modifying a List Inside a Function
How to See If There's an Available and Active Network Connection in Python
Run a Program from Python, and Have It Continue to Run After the Script Is Killed
Why Is My Pygame Display Not Responding While Waiting for Input
JSONify a SQLalchemy Result Set in Flask
Calling Filter Returns <Filter Object at ... >
How to Input Integers Using Input in Python
How to Find the Last Occurrence of an Item in a Python List
Purpose of "%Matplotlib Inline"
Generating a List of Random Numbers, Summing to 1
Embedding a Matplotlib Figure Inside a Wxpython Panel
Django Filefield with Upload_To Determined at Runtime
How Would I Access Variables from One Class to Another
Calculating Direction of the Player to Shoot Pygame
Python3: Importerror: No Module Named '_Ctypes' When Using Value from Module Multiprocessing