How to install pip with Python 3?

1,640,154

Solution 1

edit: Manual installation and use of setuptools is not the standard process anymore.

If you're running Python 2.7.9+ or Python 3.4+

Congrats, you should already have pip installed. If you do not, read onward.

If you're running a Unix-like System

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.

Installing on Debian (Wheezy and newer) and Ubuntu (Trusty Tahr and newer) for Python 2.x

Run the following command from a terminal:

sudo apt-get install python-pip 

Installing on Debian (Wheezy and newer) and Ubuntu (Trusty Tahr and newer) for Python 3.x

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

Installing pip on CentOS 7 for Python 2.x

On 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

Installing pip on CentOS 7 for Python 3.x

Assuming 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

If your Unix/Linux distro doesn't have it in package repos

Install using the manual way detailed below.

The manual way

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.

Solution 2

I was able to install pip for python 3 on Ubuntu just by running sudo apt-get install python3-pip.

Solution 3

Python 3.4+ and Python 2.7.9+

Good news! Python 3.4 (released March 2014) ships with Pip. This is the best feature of any Python release. It makes the community's wealth of libraries accessible to everyone. Newbies are no longer excluded by the prohibitive difficulty of setup. In shipping with a package manager, Python joins Ruby, Nodejs, Haskell, Perl, Go--almost every other contemporary language with a majority open-source community. Thank you Python.

Of course, that doesn't mean Python packaging is problem solved. The experience remains frustrating. I discuss this at Does Python have a package/module management system?

Alas for everyone using an earlier Python. Manual instructions follow.

Python ≤ 2.7.8 and Python ≤ 3.3

Follow my detailed instructions at https://stackoverflow.com/a/12476379/284795 . Essentially

Official instructions

Per https://pip.pypa.io/en/stable/installing.html

Download get-pip.py, being careful to save it as a .py file rather than .txt. Then, run it from the command prompt.

python get-pip.py

You possibly need an administrator command prompt to do this. Follow http://technet.microsoft.com/en-us/library/cc947813(v=ws.10).aspx

For me, this installed Pip at C:\Python27\Scripts\pip.exe. Find pip.exe on your computer, then add its folder (eg. C:\Python27\Scripts) to your path (Start / Edit environment variables). Now you should be able to run pip from the command line. Try installing a package:

pip install httpie

There you go (hopefully)!

Solution 4

if you're using python 3.4+

just type:

python3 -m pip

Solution 5

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
Share:
1,640,154
deamon
Author by

deamon

Updated on July 08, 2022

Comments

  • deamon
    deamon almost 2 years

    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?

  • talljosh
    talljosh about 12 years
    It's worth noting that the distribute install script has a --user flag that will install distribute just for the current user.
  • yoniLavi
    yoniLavi over 11 years
    Then use pip-3.2 install (replace 3.2 with your version) to install the packages - also see stackoverflow.com/questions/10763440/…
  • Tyler Crompton
    Tyler Crompton about 11 years
    How does one use distribute to install pip? I can't seem to figure it out.
  • wkl
    wkl about 11 years
    @TylerCrompton - easy_install pip.
  • Jonathan Hartley
    Jonathan Hartley about 11 years
    I ran "python3.3 distribute_setup.py". It seemed to work but the only easy_install on my PATH now are "easy_install" in Python2.7, plus "easy_install-2.6 easy_install-3.2 easy_install-2.5 easy_install-2.7" :-\
  • Dennis
    Dennis about 11 years
    Unable to locate package python3-pip. Has it been renamed?
  • Anonymous Coward
    Anonymous Coward almost 11 years
    Are you using Ubuntu 12.04 LTS? It's not available there.
  • MCP
    MCP almost 11 years
    I think I've read about easy_install being depreciated due to insecure connections. I'd read up before using easy_install.
  • wegry
    wegry almost 11 years
    distribute has since been superseded by [setup_tools] (pypi.python.org/pypi/setuptools).
  • ehime
    ehime over 10 years
    +1 Confirmed working on ubuntu 13.04 after sudo apt-get install -y python3.3 and using type pip3
  • Admin
    Admin almost 10 years
    After python get-pip.py, I also make a symlink from pip3 in /Library/Frameworks/Python.framework/Versions/3.3/bin (for example) to my system PATH, to make pip3 available on command line.
  • lfx_cool
    lfx_cool almost 10 years
    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.
  • treesAreEverywhere
    treesAreEverywhere over 9 years
    I just installed python 3.4.1 from scratch on windows 8. Where is pip? How can i start it?
  • Rob Agar
    Rob Agar over 9 years
    Ubuntu 14.04, just did apt-get install python3-dev, python 3.4 installed, no pip :(
  • newguy
    newguy over 9 years
    I can install pip3.4 with Python 3.4 on CentOS 6.5. But I used the same method and failed to install pip3.4 on CentOS 7. Python3.4 is OK though.
  • João dos Reis
    João dos Reis over 9 years
    @treesAreEverywhere it'll be in your Python installation. Add the Python bin folder to your path.
  • WoJ
    WoJ over 9 years
    From pythonhosted.org/distribute: "Distribute is a deprecated fork of the Setuptools project.". It is abandoned and not being maintained anymore.
  • WoJ
    WoJ over 9 years
    The version I just installed (Python 3.4.2 (v3.4.2:ab2c023a9432, Oct 6 2014, 22:15:05) [MSC v.1600 32 bit (Intel)] on win32) does not have pip anywhere.
  • William Patton
    William Patton about 9 years
    I also just ran this on RPi and used it with sudo pip-3.2 install [packageName]
  • abarnert
    abarnert about 9 years
    This is not true: "And, alas for everyone using an earlier Python. There's no plan to ship Pip to you." pip is shipped with 2.7.9+ as well as 3.4.0+. Of course that doesn't help people on 2.6 or 3.2, but the majority of people who need to use an earlier Python than 3.4 need to use 2.7.
  • james-see
    james-see over 8 years
    For some reason on my instance of Ubuntu 14.04 with python3.4 already installed from apt-get, I also had to run sudo easy_install3 pip and then pip3 install works from that point on.
  • hamx0r
    hamx0r over 8 years
    This helped until the mkvirtualenv py3 line - on OS X El Capitan, i get a command not found error. Also, to actually use python 3 after using brew to install it, i have to run python3 rather than just python which still maps to python 2.7. are there different steps for El Capitan?
  • silverdagger
    silverdagger over 8 years
    @hamx0r you would run python3 or you could symlink it:
  • Water
    Water over 8 years
    pip3 was not installed when I installed Python 3.4, I had to follow instructions here to get it.
  • mahacoder
    mahacoder over 8 years
    I installed pip the manual way , but now I have pip and pip3 both. If I run any of them with -V option, I get pip 8.0.2 from /Library/Frameworks/Python.framework/Versions/3.5/lib/python‌​3.5/site-packages (python 3.5). How do I keep only one and remove the other?
  • tamale
    tamale about 8 years
    pip is unfortunately not included with python 3.4 if you're on centos. See here for details: stackoverflow.com/questions/32618686/…
  • wkl
    wkl about 8 years
    @ak31 - pip is likely a symbolic link to pip3. If you do an ls -l $(which pip), it should probably show that.
  • wkl
    wkl about 8 years
    @tamale - Python 3.4 isn't a default package on CentOS 7 - I've included some additional instructions for people running CentOS 7, assuming they use EPEL to install Python 3.4.
  • Admin
    Admin about 8 years
    Pip's website says that it already comes with Python 3.4+ if you downloaded from python.org. However, when I type pip on terminal, I get command not found. So I decided to go through the python3's install docs again, where it mentions that python and pip should be accessed using the commands python3 and pip3 instead. This is not obvious from the documentation on either site.
  • Antwane
    Antwane about 8 years
    Thank you, this command pointed my mistake: I built python 3.5 without libssl-dev package, so PIP was not built
  • zalpha314
    zalpha314 about 8 years
    After you install python3-pip, if the package cannot be found, try python3 -m pip
  • Mona Jalal
    Mona Jalal almost 8 years
    ImportError: No module named 'pip' after I did all these for python3.4.1 from source off the original python website! Python 3.4.1 (default, Aug 4 2016, 16:56:02) [GCC 4.2.1 Compatible Apple LLVM 7.3.0 (clang-703.0.31)] on darwin
  • Xaser
    Xaser over 7 years
    seems to be just pip3 now
  • PlasmaBinturong
    PlasmaBinturong over 7 years
    For those who want to use the manual install (get-pip.py), this won't work with python3.0 to 3.2...
  • Karmavil
    Karmavil over 7 years
    Thabk you! @yoniLavi and thanks for the link also. Lot of people saying virtualenv/..wrapper but these tools are installed via pip.. So for those who doesn't know (like me) if it's irrelevant the way you install pip we've got here an obvious question. I will use pip3 by now thank you
  • not2qubit
    not2qubit about 7 years
    This also worked on cygwin! First update: pip2 install --upgrade pip and apt-cyg install python3. Then what you wrote and you've got pip3.
  • user25
    user25 about 7 years
    where is windows? I don't say that I'm using only windows, I have no problem to install all of this in ubuntu, by author didn't mention linux, why there such a discrimination, like python, pip doesn't exist for windows...
  • loretoparisi
    loretoparisi about 7 years
    This will install pip for python not for python3, the right way is sudo apt-get install python3-pip
  • 3pitt
    3pitt over 6 years
    pip3 is works, but I had to use sudo pip3 install (for pandas at least)
  • CodeFinity
    CodeFinity over 6 years
    @loretoparisi That's what it says in the Answer up there. M Installing it now... :|
  • CodeFinity
    CodeFinity over 6 years
    I did have to follow @jamescampbell tip to get it to work fully though.
  • CodeFinity
    CodeFinity over 6 years
    Collecting pip Using cached pip-9.0.1-py2.py3-none-any.whl Installing collected packages: pip Successfully installed pip-8.1.1 You are using pip version 8.1.1, however version 9.0.1 is available. You should consider upgrading via the 'pip install --upgrade pip' command. This is bit strange...I'm fine with v8, I guess, but it always keeps saying the same message when I try to 'upgrade.' :|
  • turiyag
    turiyag about 6 years
    On CentOS:6 docker image: python3 -m pip /usr/bin/python3: No module named pip
  • will
    will almost 6 years
    It is a bit confusing. I can report that the Debian command worked for Ubuntu 16 and Python3: sudo apt-get install python3-pip. pip was NOT installed with Python 3 for this Ubuntu's PPA. I used to use Python a lot -- There's really no need for a disregard for forward migration ... Yet it still happens. Some kind of interface management or poly-fill approach would save lots of trouble. Witness 17 x answers to the same question and more than a dozen comments on the accepted answer. Me thinks a smell.
  • j3ffyang
    j3ffyang almost 6 years
    wget bootstrap.pypa.io/get-pip.py && python get-pip.py This works for me and upgrades pip3
  • Christopher Hunter
    Christopher Hunter over 5 years
    Of all these methods, this is the only way I managed to get pip to install for python3.5 when I have both 3.4 and 3.5 on the system.
  • MaxiReglisse
    MaxiReglisse about 5 years
    that did the trick for me, for portalocker: python3 -m pip install portalocker
  • Nicholas Leader
    Nicholas Leader almost 5 years
    You can also do this in PowerShell of course. Also the '-32' refers to the 32bit version of Python. So for me the path was .\Python37\scripts\ as I was targeting the 64bit version of Python.
  • Mark Amery
    Mark Amery over 4 years
    This doesn't answer the question asked, which was about how to install pip, not how to install stuff with pip.
  • None
    None over 4 years
    can't thank you enough. managing per version install/uninstall is a nightmare no longer.
  • aysebilgegunduz
    aysebilgegunduz almost 4 years
    The best way to avoid this kind of problem is using pyenv. I tried this solution without using pyenv it didn't solve the TLS problem.
  • MayTheSForceBeWithYou
    MayTheSForceBeWithYou almost 3 years
    Don't forget to use "python3" anywhere you see a command solution that uses "python ..." if your alias is set up to use python3 instead of python. Didn't click for me for a good couple hours
  • Vasiliki
    Vasiliki almost 3 years
    Correct me if I am wrong but believe it's the same for Centos and amazon linux , sudo yum install python3-pip