I want to install pip. It should support Python 3, but it requires setuptools, which is available only for Python 2.
How can I install pip with Python 3?
I want to install pip. It should support Python 3, but it requires setuptools, which is available only for Python 2.
How can I install pip with Python 3?
Below video is how I did in cygwin:
https://asciinema.org/a/hSu4kmJ6wb7b2UiuvxiXqtgGK
There is weirdness in python's
pip
,pip2
,pip3
craziness. In crazy situations like these, it is imperative that there is less talking or explanations, but instead demonstrate things out.I was able to install pip for python 3 on Ubuntu just by running
sudo apt-get install python3-pip
.Single Python in system
To install packages in Python always follow these steps:
python 2.x
:sudo python -m pip install [package]
python 3.x
:sudo python3 -m pip install [package]
Note: This is assuming no alias is set for
python
Through this method, there will be no confusion regarding which python version is receiving the package.
Multiple Pythons
Say you have
python3 ↔ python3.6
andpython3.7 ↔ python3.7
sudo python3 -m pip install [package]
sudo python3.7 -m pip install [package]
This is essentially the same method as shown previously.
Note 1
How to find which python, your
python3
command spawns:Notice python 3.6.6 in the second line.
Note 2
Change what
python3
orpython
points to: https://askubuntu.com/questions/320996/how-to-make-python-program-command-execute-python-3I'm not sure when exactly this was introduced, but it's installed pip3 for me when it didn't already exist.
Assuming you are in a highly restricted computer env (such as myself) without root access or ability to install packages...
I had never setup a fresh/standalone/raw/non-root instance of Python+virtualenv before this post. I had do quite a bit of Googling to make this work.
python3
forpython
if you are python2 user.wget https://pypi.python.org/packages/source/v/virtualenv/virtualenv-x.y.z.tar.gz
tar -xzvf virtualenv-x.y.z.tar.gz
python3 virtualenv-x.y.z/virtualenv.py --python $(which python3) /path/to/new/virtualenv
source /path/to/new/virtualenv/bin/activate
virtualenv
package includes a standalone version ofpip
andsetuptools
that are auto-magically installed into each new virtualenv. This solves the chicken and egg problem.which python3
should give:/path/to/new/virtualenv/bin/python3
pip
is also available in the virtualenv viawhich pip
... should give:/path/to/new/virtualenv/bin/pip
Then... pip, pip, pip!
Final tip to newbie Pythoneers: You don't think you need virtualenv when you start, but you will be happy to have it later. Helps with "what if" installation / upgrade scenarios for open source / shared packages.
Ref: https://virtualenv.pypa.io/en/latest/installation.html
If your Linux distro came with Python already installed, you should be able to install PIP using your system’s package manager. This is preferable since system-installed versions of Python do not play nicely with the get-pip.py script used on Windows and Mac.
Advanced Package Tool (Python 2.x)
Advanced Package Tool (Python 3.x)
pacman Package Manager (Python 2.x)
pacman Package Manager (Python 3.x)
Yum Package Manager (Python 2.x)
Yum Package Manager (Python 3.x)
Dandified Yum (Python 2.x)
Dandified Yum (Python 3.x)
Zypper Package Manager (Python 2.x)
Zypper Package Manager (Python 3.x)