How to install pip for Python 3 on Mac OS X?
Solution 1
UPDATE: This is no longer necessary with Python3.4. It installs pip3 as part of the stock install.
I ended up posting this same question on the python mailing list, and got the following answer:
# download and install setuptools
curl -O https://bootstrap.pypa.io/ez_setup.py
python3 ez_setup.py
# download and install pip
curl -O https://bootstrap.pypa.io/get-pip.py
python3 get-pip.py
Which solved my question perfectly. After adding the following for my own:
cd /usr/local/bin
ln -s ../../../Library/Frameworks/Python.framework/Versions/3.3/bin/pip pip
So that I could run pip directly, I was able to:
# use pip to install
pip install pyserial
or:
# Don't want it?
pip uninstall pyserial
Solution 2
I had to go through this process myself and chose a different way that I think is better in the long run.
I installed homebrew
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
then:
brew doctor
The last step gives you some warnings and errors that you have to resolve. One of those will be to download and install the Mac OS X command-line tools.
then:
brew install python3
This gave me python3
and pip3
in my path.
pieter$ which pip3 python3
/usr/local/bin/pip3
/usr/local/bin/python3
Solution 3
Install Python3 on mac
1. brew install python3
2. curl https://bootstrap.pypa.io/get-pip.py | python3
3. python3
Use pip3
to install modules
1. pip3 install ipython
2. python3 -m IPython
:)
Solution 4
Here is my simple solution:
If you have python2 and python3 both installed in your system, the pip upgrade will point to python2 by default. Hence, we must specify the version of python(python3) and use the below command:
python3 -m pip install --upgrade pip
This command will uninstall the previously installed pip and install the new version- upgrading your pip.
This will save memory and declutter your system.
Image - How the upgrading of pip in Python3 works on MacOS
Solution 5
Plus: when you install requests with python3, the command is:
pip3 install requests
not
pip install requests
![Travis Griggs](https://i.stack.imgur.com/YGip7.png?s=256&g=1)
Travis Griggs
Updated on January 11, 2022Comments
-
Travis Griggs over 2 years
OS X (Mavericks) has Python 2.7 stock installed. But I do all my own personal Python stuff with 3.3. I just flushed my 3.3.2 install and installed the new 3.3.3. So I need to install
pyserial
again. I can do it the way I've done it before, which is:- Download pyserial from pypi
- untar pyserial.tgz
- cd pyserial
python3 setup.py install
But I'd like to do like the cool kids do, and just do something like
pip3 install pyserial
. But it's not clear how I get to that point. And just that point. Not interested (unless I have to be) in virtualenv yet. -
Travis Griggs over 10 yearsHow does easy_install determine that it's for python3? I have a
\usr\local\bin\easy_install
dated Sep 13 2012. I'm suspicious that is from/for the stock 2.7. Sadly,easy_install --version
isn't helpful.--help
doesn't even give any useful hints. -
l'L'l over 10 years@TravisGriggs - do you also have 2.7 installed? i was assuming you were only using 3.3.x.
-
Travis Griggs over 10 yearsI have not uninstalled the stock 2.7 version that is part of OSX. That would seem like a Bad Idea(tm).
-
l'L'l over 10 years@TravisGriggs, well uninstalling 2.7 can be a bad idea if not done correctly. try typing
which easy_install
in terminal following byless <path/to/>easy_install
. It should give me more information on the version you're using. -
Travis Griggs over 10 yearsYeah, I had checked that. It's a binary, not a symlink. Since python3 mostly installs in
/Library/Frameworks/Python/...
, that makes me strongly suspicious that it is for 2.7. -
l'L'l over 10 yearsIf your pythonpath is set to use 3.3.x then easy_installing pip should associate it with the latest version — or at least that's how mine works.
-
jfs over 10 yearsto avoid confusion with
pip
that installs for Python 2.7, you could create the symlink namedpip3
instead of ambiguouspip
-
nonex over 9 yearsThanks for this, was looking for a good solution. For people seeing this in the future (who will get the same message I got from ruby), the Homebrew installer has moved and the new command is:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
-
radtek over 8 yearsI didn't have to create a symlink, one was created automatically named pip3
-
Madhulika Mukherjee over 8 yearsFollowing your answer step by step solved my problem. Thanks!
-
Taylor D. Edmiston about 8 yearsJust to clarify for others, the script downloaded is from the official host for pip - pypi.python.org/pypi/pip
-
Gardner Bickford about 8 yearsPlease add https to this example
-
Alan Dong about 8 years@GardnerBickford Added https
-
bubakazouba almost 8 years
-
shazeline almost 8 yearsbootstrap.pypa.io/ez_setup.py and bootstrap.pypa.io/get-pip.py are the updated links, though pip3 comes installed with python3 as OP mentioned.
-
tash over 7 yearsThank you for that update! I've been searching for so long on how to install pip, only to find that it was already on my system! Just had to use "pip3". Cheers!
-
flik over 5 years$ which pip3 python3 /usr/local/bin/python3 getting result but when I try pip3 --version then error: pip3: command not found
-
Devran Cosmo Uenal almost 5 yearsThanks! This is exactly what I was looking for — running macOS Catalina.
-
Ashish Rawat about 4 yearsThanks a lot, saved quite some efforts.
-
Polluks over 3 yearsLatest command
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
-
kamp over 2 yearsThis is by far straight to the point solution!