How to install pip for Python 3 on Mac OS X?

PythonMacosPython 3.xPipPython 3.3

Python Problem Overview


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.

Python Solutions


Solution 1 - Python

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 - Python

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 - Python

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 - Python

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 - Python

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

pip3 install requests

not

pip install requests

Solution 6 - Python

  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)

Solution 7 - Python

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

Solution 8 - Python

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

Solution 9 - Python

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)

Solution 10 - Python

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

Solution 11 - Python

pip is installed automatically with python2 using brew:

  1. brew install python3
  2. pip3 --version

Solution 12 - Python

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

Solution 13 - Python

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.

Solution 14 - Python

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

Solution 15 - Python

I'm using MacOS 11.6 and in my case I did two things;

  1. Install Python 3 from https://www.python.org/downloads/macos/ clicking on first link Download macOS 64-bit universal2 installer from Stable Releases list

  2. Create alias for Python3 running the following command on Terminal echo "alias python='/usr/bin/python3'" > ~/.bash_profile

After that open a new terminal and type python -V to check if the version of python 3 is enabled by default for your use so now you can use the command pip3 to install your packages like pip3 install somepackage

Solution 16 - Python

use port to install it, it is better than brew, in case you have an old machine.

sudo port install py38-pip

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionTravis GriggsView Question on Stackoverflow
Solution 1 - PythonTravis GriggsView Answer on Stackoverflow
Solution 2 - PythonPieter BreedView Answer on Stackoverflow
Solution 3 - PythonAlan DongView Answer on Stackoverflow
Solution 4 - PythonDivyaMaheswaranView Answer on Stackoverflow
Solution 5 - PythonstevenView Answer on Stackoverflow
Solution 6 - PythonnorthtreeView Answer on Stackoverflow
Solution 7 - Pythonl'L'lView Answer on Stackoverflow
Solution 8 - PythonDenis KutlubaevView Answer on Stackoverflow
Solution 9 - PythonLiyaliView Answer on Stackoverflow
Solution 10 - PythonLincolnView Answer on Stackoverflow
Solution 11 - PythonDarmen AmanbayevView Answer on Stackoverflow
Solution 12 - Pythonuser10285689View Answer on Stackoverflow
Solution 13 - PythonHari_pbView Answer on Stackoverflow
Solution 14 - PythonIvan ZeleninView Answer on Stackoverflow
Solution 15 - PythonbrunocrtView Answer on Stackoverflow
Solution 16 - PythonSherif O.View Answer on Stackoverflow