133

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:

  1. Download pyserial from pypi
  2. untar pyserial.tgz
  3. cd pyserial
  4. 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.

nbro
  • 12,226
  • 19
  • 85
  • 163
Travis Griggs
  • 18,930
  • 17
  • 76
  • 137

14 Answers14

143

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
tranisstor
  • 52
  • 6
Travis Griggs
  • 18,930
  • 17
  • 76
  • 137
  • 8
    to avoid confusion with `pip` that installs for Python 2.7, you could create the symlink named `pip3` instead of ambiguous `pip` – jfs Mar 24 '14 at 06:03
  • 5
    I didn't have to create a symlink, one was created automatically named pip3 – radtek Dec 15 '15 at 17:48
  • Following your answer step by step solved my problem. Thanks! – Madhulika Mukherjee Mar 22 '16 at 20:39
  • 6
    404 for https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py – bubakazouba Jun 28 '16 at 00:38
  • 1
    https://bootstrap.pypa.io/ez_setup.py and https://bootstrap.pypa.io/get-pip.py are the updated links, though pip3 comes installed with python3 as OP mentioned. – shazeline Sep 06 '16 at 20:08
  • Thank 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! – tash Mar 26 '17 at 19:53
68

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
Pieter Breed
  • 5,299
  • 4
  • 40
  • 58
  • 2
    Thanks 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)"` – nonex Nov 05 '14 at 05:46
  • Latest command `/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"` – Polluks Feb 16 '21 at 07:37
62

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

:)

Alan Dong
  • 3,443
  • 32
  • 32
17

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

DivyaMaheswaran
  • 656
  • 1
  • 10
  • 16
14

Plus: when you install requests with python3, the command is:

pip3 install requests

not

pip install requests
steven
  • 514
  • 6
  • 13
12
  1. brew install python3
  2. create alias in your shell profile

    • eg. alias pip3="python3 -m pip" in my .zshrc

➜ ~ pip3 --version

pip 9.0.1 from /usr/local/lib/python3.6/site-packages (python 3.6)

northtree
  • 6,212
  • 9
  • 45
  • 66
7

To use Python EasyInstall (which is what I think you're wanting to use), is super easy!

sudo easy_install pip

so then with pip to install Pyserial you would do:

pip install pyserial
l'L'l
  • 40,316
  • 6
  • 77
  • 124
  • 4
    How 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. – Travis Griggs Nov 19 '13 at 23:32
  • 1
    @TravisGriggs - do you also have 2.7 installed? i was assuming you were only using 3.3.x. – l'L'l Nov 19 '13 at 23:39
  • 3
    I have not uninstalled the stock 2.7 version that is part of OSX. That would seem like a Bad Idea(tm). – Travis Griggs Nov 19 '13 at 23:42
  • @TravisGriggs, well uninstalling 2.7 can be a bad idea if not done correctly. try typing `which easy_install` in terminal following by `less easy_install`. It should give me more information on the version you're using. – l'L'l Nov 19 '13 at 23:51
  • Yeah, 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. – Travis Griggs Nov 19 '13 at 23:53
  • If 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. – l'L'l Nov 19 '13 at 23:56
5

Also, it's worth to mention that Max OSX/macOS users can just use Homebrew to install pip3.

$> brew update
$> brew install python3
$> pip3 --version
pip 9.0.1 from /usr/local/lib/python3.6/site-packages (python 3.6)
Liyali
  • 5,444
  • 2
  • 23
  • 40
5

On Mac OS X Mojave python stands for python of version 2.7 and python3 for python of version 3. The same is pip and pip3. So, to upgrade pip for python 3 do this:

~$ sudo pip3 install --upgrade pip
Denis Kutlubaev
  • 13,009
  • 6
  • 76
  • 67
4

On MacOS 10.12

download pip: pip as get-pip.py

download python3: python3

  1. install python3
  2. open terminal: python3 get-pip.py
  3. pip3 is available
Jordan Stewart
  • 2,687
  • 3
  • 20
  • 32
Lincoln
  • 161
  • 4
4

pip is installed automatically with python2 using brew:

  1. brew install python3
  2. pip3 --version
Darmen Amanbayev
  • 4,751
  • 3
  • 26
  • 49
  • $ which pip3 python3 /usr/local/bin/python3 getting result but when I try pip3 --version then error: pip3: command not found – flik Feb 20 '19 at 07:25
1

simply run following on terminal if you don't have pip installed on your mac.

sudo easy_install pip

download python 3 here: python3

once you're done with these 2 steps, make sure to run the following to verify whether you've installed them successfully.

python3 --version
pip3 --version
0

For a fresh new Mac, you need to follow below steps:-

  1. Make sure you have installed Xcode
  2. sudo easy_install pip
  3. /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  4. brew doctor
  5. brew doctor
  6. brew install python3

And you are done, just type python3 on terminal and you will see python 3 installed.

Harry_pb
  • 4,892
  • 1
  • 30
  • 44
0

I had the same problem with python3 and pip3. Decision: solving all conflicts with links and other stuff when do

brew doctor

After that

brew reinstall python3