How to Install Pip on Mac OSX

August 23, 2019  1 minute read  

Learn how to handle bash: pip: command not found error.

Reasons

1) One possible reason for this error could be pip was not installed or its path wasn’t configured correctly. In general, reinstalling pip can fix this error.


bash: pip: command not found

2) Another reason is you have Python3 installed and you could use pip3 instead of pip. To check if you have pip3, you can run


pip3 --version

Install Pip

As of 2019, you can install pip using a Python script Download get-pip.py provided by https://pip.pypa.io using the following command.

1) Run the following command via your terminal.

 
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py

Output:

 
% Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 1733k  100 1733k    0     0  3154k      0 --:--:-- --:--:-- --:--:-- 3152k

2) After you download get-pip.py Python file, run it using this command. You have to type in your password.


sudo python get-pip.py

Output:


Password:  
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020.    
Please upgrade your Python as Python 2.7 won't be maintained after 
that date. A future version of pip will drop support for Python 2.7.   
More details about Python 2 support in pip,   
can be found at    
https://pip.pypa.io/en/latest/development/release-process/#python-2-support   
Collecting pip   
  Downloading https://files.pythonhosted.org/packages/30/db/     
  9e38760b32e3e7f40cce46dd5fb107b8c73840df38f0046d8e6514e675a1/   
  pip-19.2.3-py2.py3-none-any.whl (1.4MB)
     |████████████████████████████████| 1.4MB 1.8MB/s 
Installing collected packages: pip
  Found existing installation: pip 19.2.3
    Uninstalling pip-19.2.3:
      Successfully uninstalled pip-19.2.3
Successfully installed pip-19.2.3

3) After you done installing, run this command to check if pip is installed.


pip --version

Possible output:


pip 19.2.3 from /Library/Frameworks/Python.framework/
Versions/3.7/lib/python3.7/site-packages/pip (python 3.7)

4) Remember to clean up after installing pip by removing the installer file, get-pip.py.


rm get-pip.py

Note

1) To install a package using pip, you can run pip install package_name or pip3 install package_name.

2) Note that Python 2.7 will not be maintained starting January 1st, 2020. Check out How to Install Python 3 on Mac OSX article to install Python 3.

Support Jun

Thank you for reading!    Support JunSupport Jun

Support Jun on Amazon US

Support Jun on Amazon Canada

If you are preparing for Software Engineer interviews, I suggest Elements of Programming Interviews in Java for algorithm practice. Good luck!

You can also support me by following me on Medium or Twitter.

Feel free to contact me if you have any questions.

Comments