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?
For Ubuntu 12.04 or older,
sudo apt-get install python3-pip
won't work. Instead, use:
sudo apt-get install python3-setuptools ca-certificates
sudo easy_install3 pip
What’s New In Python 3.4
...
pip should always be available
...
By default, the commands pipX and pipX.Y will be installed on all platforms (where X.Y stands for the version of the Python installation), along with the pip Python package and its dependencies.
https://docs.python.org/3/whatsnew/3.4.html#whatsnew-pep-453
so if you have python 3.4 installed, you can just: sudo pip3 install xxx
For python3 try this:
wget https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py -O - | python
The good thing is that It will also detect what version of python you have (even if it's an environment of python in your custom location). After this you can proceed normally with (for example)
pip install numpy
source: https://pypi.python.org/pypi/setuptools/1.1.6#upgrading-from-setuptools-0-6
And for Windows 8.1/10 OS Users just open cmd (command prompt)
write this : C:\Users\%USERNAME%\AppData\Local\Programs\Python\Python36-32\Scripts
then
just write this : pip3 install
{name of package}
Hint: the location of folder Python36-32
may get different for new python 3.x versions
edit: Manual installation and use of setuptools
is not the standard process anymore.
Congrats, you should already have pip
installed. If you do not, read onward.
You can usually install the package for pip
through your package manager if your version of Python is older than 2.7.9 or 3.4, or if your system did not include it for whatever reason.
Instructions for some of the more common distros follow.
Run the following command from a terminal:
sudo apt-get install python-pip
Run the following command from a terminal:
sudo apt-get install python3-pip
Note:
On a fresh Debian/Ubuntu install, the package may not be found until you do:
sudo apt-get update
pip
on CentOS 7 for Python 2.xOn CentOS 7, you have to install setup tools first, and then use that to install pip
, as there is no direct package for it.
sudo yum install python-setuptools
sudo easy_install pip
pip
on CentOS 7 for Python 3.xAssuming you installed Python 3.4 from EPEL, you can install Python 3's setup tools and use it to install pip
.
# First command requires you to have enabled EPEL for CentOS7
sudo yum install python34-setuptools
sudo easy_install pip
Install using the manual way detailed below.
If you want to do it the manual way, the now-recommended method is to install using the get-pip.py
script from pip's installation instructions.
Install pip
To install pip, securely download get-pip.py
Then run the following (which may require administrator access):
python get-pip.py
If
setuptools
is not already installed,get-pip.py
will install setuptools for you.
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
for python
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 of pip
and setuptools
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 via which 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