On Linux or MacOS:
python -m ensurepip --upgrade
If you want to install pip for Python 3, replace python with python3.
See https://pip.pypa.io/en/stable/installation/ for more details.
Answer from Scott Tesler on Stack OverflowOn Linux or MacOS:
python -m ensurepip --upgrade
If you want to install pip for Python 3, replace python with python3.
See https://pip.pypa.io/en/stable/installation/ for more details.
TL;DR — One-line solution.
Run the following command for Python v2.7 (default on Mac as of 2021)
curl https://bootstrap.pypa.io/pip/2.7/get-pip.py | python
Run the following command for Python v3
curl https://bootstrap.pypa.io/get-pip.py | python
Or the following if you have it installed as Python 3
curl https://bootstrap.pypa.io/get-pip.py | python3
Another GIF image you said? Here you go!

The following used to work in 2019 and before
All you had to do was:
sudo easy_install pip
2019: easy_install has been deprecated. Check Method #2 below for the preferred installation!
Details:
OK, I read the solutions given above, but here's an easy solution to install
pip.
The macOS comes with the Python environment installed. But to make sure that you have Python installed open the terminal and run the following command.
python --version
If this command returns a version number that means Python exists. This also means that you already have access to easy_install considering you are using macOS or OS X.
Now, all you have to do is run the following command.
sudo easy_install pip
After that, pip will be installed and you'll be able to use it for installing other packages.
P.S. I ended up blogging a post about it. QuickTip: How Do I Install pip on macOS or OS X?
Method #2: Two line solution
easy_install has been deprecated. Please use get-pip.py instead.
Download and install PIP
curl https://bootstrap.pypa.io/get-pip.py | python
Videos
I'm brand new to Python and I'm trying to install pip to Python on my Mac. I did try to check if it was already there but the methods I used didn't work so far.
I have gone through a bunch of different tutorials but they don't work.
I've tried using what this website tells me: https://github.com/pypa/get-pip?tab=readme-ov-file
But Python keeps saying "SyntaxError" at $ and https
Can someone help me?
UPDATE: This is no longer necessary as of Python3.4. pip3 is installed as part of the general Python3 installation.
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
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
I recently used brew to install tkinter package. It changed sys path variable and ventured into opt directory as well. Is that ok? Post this pydoc3 is showing duplicate packages. Would pip3 avoid this and make it clean. Which is recommended?
well, packages for OSX may include packages for python.
pip is a packager for the python world - you should only ever be able to install python-things with it; homebrew is a package manager targetted at OSX; it doesn't impose any restrictions onto what software you can install with it - since python is a subset of software.
installing things with brew will install them into /usr/local/;
installing things with pip will fetch packages from the Python Package Index, and it will install them in a place where your python interpreter will find them: either into your home directory (e.g. ~/.local/lib/python2.7/site-packages/) or in some global search-path of your python interpreter (e.g. /usr/local/lib/python2.7/dist-packages/)
if you have installed the python interpreter via brew, then chances are high that any python-package installed via brew will be usable out of the box.
Homebrew is a package manager, similar to apt on ubuntu or yum on some other linux distros. Pip is also a package manager, but is specific to python packages. Homebrew can be used to install a variety of things such as databases like MySQL and mongodb or webservers like apache or nginx.
pip install pillow should place the package in your PYTHONPATH whereas if you install it with brew, unless you've added the appropriate directories to your PYTHONPATH, python won't be able to import anything from it. If you're installing a python module, definitely use pip
Maybe it is time to consider using virtualenv. Virtualenv creates self-contained python environments using the python version you specify. After activating the new virtual environment, everything you install using pip goes under that environment. This helps avoid situations like the one you described.
E.g. create and activate a new python environment using the default python:
# create environment
$ virtualenv --distribute myproject
New python executable in myproject/bin/python
Installing distribute...done.
Installing pip...done.
# activate environment
$ . ./myproject/bin/activate
# check default python
(myproject)$ which python
/Users/me/myproject/bin/python
It is suggested to use the --distribute options to indicate that distribute should be used for installing packages in the new environment instead of (the older) setuptools. After activation your command prompt changes to indicate which python environment is active.
Now install some package. The files will go into myproject directory:
# install django
(myproject)$ pip install django
...
# search for django dir
(myproject)$ find myproject -iname django
myproject/lib/python2.7/site-packages/django
Finally, deactivate:
# deactivate and check for default python
(myproject)$ deactivate
$ which python
/usr/bin/python
To create an environment using a non-default version of python:
$ virtualenv --distribute -p /path/to/custom/python mynewproject
By default virtualenv will copy to the new environment any packages installed for the python version you use to bootstrap it. To prevent this and create an empty environment use the --no-site-packages option. This is especially useful to create environments which can be exactly replicated e.g. from development to production.
Update: As of version 1.7 --no-site-packages has become the default behaviour of virtualenv.
If you want more details, there are plenty of tutorials and blog posts online. E.g.:
- Notes on using pip and virtualenv with Django. (most of the post is not django-specific)
- Working with virtualenv.
Give it a try and I'm sure you'll stick with it.
Note: Make sure that your executable scripts do not have the python interpreter hardcoded. I.e. their first line should be #!/usr/bin/env python and not something like #!/usr/bin/python.
My suggestions:
Install the xcode commandline tools package via Xcode -> Preferences -> Downloads-> Components:

Install homebrew (upgrade your path in
.profile,.SHELLrcor whatever to include/usr/local/binbefore the system default like/usr/bin).For python first install all the prereqs by themselves:
brew install readline sqlite gdbm pkg-configbrew install python --framework --universal- update your path so that it uses the right distutils:
export PATH=/usr/local/share/python:$PATH
easy_install pippip install virtualenvpip install virtualenvwrapper- Include
export PYTHONPATH=/usr/local/lib/python:$PYTHONPATH