656

I downloaded pip and ran python setup.py install and everything worked just fine. The very next step in the tutorial is to run pip install <lib you want> but before it even tries to find anything online I get an error "bash: pip: command not found".

This is on Mac OS X. I'm assuming there's some kind of path setting that was not set correctly when I ran setup.py. How can I investigate further? What do I need to check to get a better idea of the exact cause of the problem?

EDIT: I also tried installing Python 2.7 for Mac in the hopes that the friendly install process would do any housekeeping like editing PATH and whatever else needs to happen for everything to work according to the tutorials, but this didn't work. After installing, running 'python' still ran Python 2.6 and PATH was not updated.

8
  • Did the installation of pip report it was successful?
    – jdi
    Commented Mar 20, 2012 at 2:48
  • Perhaps you need to run the command as root? Commented Mar 20, 2012 at 2:50
  • I am running terminal using sudo, so everything should be run as root. The installed did report success.
    – Trindaz
    Commented Mar 20, 2012 at 2:52
  • 89
    It's because the python3 path (\bin) doesn't have "pip" anymore, it has "pip3". Open your terminal and type "pip3 -v" and I'm sure you'll see it's there. Ever since Python 3.5 pip has been included with Python but they renamed it slightly. Hope that helps.
    – S Walsh
    Commented Feb 28, 2019 at 0:59
  • 1
    pip 3 work for me. Ex: pip3 install APScheduler
    – Dan
    Commented Oct 11, 2019 at 2:28

39 Answers 39

566

Why not just do sudo easy_install pip or if this is for python 2.6 sudo easy_install-2.6 pip?

This installs pip using the default python package installer system and saves you the hassle of manual set-up all at the same time.

This will allow you to then run the pip command for python package installation as it will be installed with the system python. I also recommend once you have pip using the virtualenv package and pattern. :)

7
  • 98
    Thanks for the suggestion, sorry but I'm a newbie sudo: easy_install: command not found
    – SSH This
    Commented Aug 9, 2013 at 15:16
  • 6
    sudo apt install python-pip? Commented Aug 31, 2018 at 18:33
  • 133
    This assumes you have easy_install installed. How is this an answer?
    – Steven
    Commented Sep 10, 2019 at 17:49
  • 2
    Easy Install is deprecated. Do not use it. Instead use pip. - setuptools.readthedocs.io/en/latest/deprecated/… Commented Mar 3, 2021 at 14:49
  • 8
    How do you use pip to install pip? Commented Apr 6, 2023 at 22:53
504

2020 Update:

For current Debian/Ubuntu, use

apt-get install python3-pip

to install pip3.


Old 2013 answer (easy_install is now deprecated):

Use setuptools to install pip: sudo easy_install pip

(I know the above part of my answer is redundant with klobucar's, but I can't add comments yet), so here's an answer with a solution to sudo: easy_install: command not found on Debian/Ubuntu: sudo apt-get install python-setuptools

Also, for python3, use easy_install3 and python3-setuptools.

For Python 3, use apt-get install python3-pip.

5
  • 16
    for pip3: sudo apt-get install python3-setuptools & sudo easy_install3 pip
    – Felix
    Commented Oct 23, 2016 at 0:48
  • this is the right answer sudo apt-get install python-setuptools followed by sudo easy_install pip Commented Apr 19, 2018 at 6:28
  • 8
    @Smily But the question states explicitly that this is for macOS, not Ubuntu Commented Mar 24, 2020 at 15:59
  • 1
    @SriHarshaChilakapati you are right and this answer seems more related: https://stackoverflow.com/a/20340173/9714920
    – Smily
    Commented Mar 25, 2020 at 16:10
  • after installing pytho3-setuptools, i have a command not found trying to execute easy_install3
    – realtebo
    Commented Jun 26, 2020 at 12:49
387

First of all: try pip3 instead of pip. Example:

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

pip3 should be installed automatically together with Python3.x. The documentation hasn't been updated, so simply replace pip by pip3 in the instructions, when installing Flask for example.

Now, if this doesn't work, you might have to install pip separately.

4
  • 4
    All those who installed ubuntu 16 should try this first.
    – l__flex__l
    Commented Nov 13, 2017 at 8:11
  • 28
    Worked for me on macOS after brew install python. Commented Sep 24, 2018 at 9:12
  • That was exactly my case. Installed Python from .pkg file.
    – ekar
    Commented Sep 26, 2018 at 8:35
  • And you can use pip2 if you are using Python 2.x
    – aris
    Commented Dec 23, 2018 at 2:11
71

Update: A more reliable modern way to access the right pip install for the right python install is to use the syntax python -m pip.

Original Answer

pip would install itself into the bin of your python installation location. It also should create a symlink to some more common location like /usr/local/bin/pip

You can either edit your ~/.profile and update your PATH to include /Library/Frameworks/Python.framework/Versions/2.6/bin, or you could create a symlink to it in a place that you know is in your path.

If you do: echo $PATH, you should see the paths currently being searched. If /usr/local/bin is in your PATH, you can do:

ln -s /Library/Frameworks/Python.framework/Versions/2.6/bin/pip /usr/local/bin

I would opt for adding the python bin to your $PATH variable.

7
  • Also, there is no /Library/Frameworks/Python.framework/Versions/2.6/ - only 2.7, and the only appeared after I ran the Python 2.7 installer moments ago. Does this mean the default Python 2.6 that comes with Mac doesn't conform to whatever ever standard file locations you assumed?
    – Trindaz
    Commented Mar 20, 2012 at 3:19
  • 2
    The system version may be here /System/Library/Frameworks/Python.framework/Versions/2.6/bin. And ~/ is your home directory with the hidden file .profile
    – jdi
    Commented Mar 20, 2012 at 3:30
  • There is no file .profile in ~/ but there is a .bash_profile. Are they the same?
    – Trindaz
    Commented Mar 20, 2012 at 3:44
  • 1
    macos: ln -s ~/Library/Python/2.7/bin/pip /usr/local/bin/pip Commented Jun 11, 2019 at 18:50
  • @Kesha Antonov that would only work if one actually installed Python into their own user home directory. And then, symlinking it to the system /usr/local/bin would potentially break for other user accounts.
    – jdi
    Commented Jun 12, 2019 at 10:30
55

I encountered this problem having downloaded python 3.x.x and trying to install awscli - pip: command not found.

Whilst following the instructions for downloading the AWS client, I changed

pip install awscli

to

pip3 install awscli

which ran the correct version.

I've made an alias on my machine to run python3 whilst typing python, which would normally run the system version 2.7. I'm not sure this is a good idea now. I think I'll just type in the commands as they intended them to be.

0
48

Check out How to Install Pip article for more information.

As of 2019,

Download get-pip.py provided by https://pip.pypa.io using the following command:
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py

Run get-pip.py using the following command:
sudo python get-pip.py

After you done installing, run this command to check if pip is installed.
pip --version

Remove get-pip.py file after installing pip.
rm get-pip.py

Pip website

1
  • Or curl -L get-pip.io | sudo python.
    – Jon-Eric
    Commented Jun 28, 2020 at 1:26
34

Install Python latest version as given here

It has many download links like numpy and scipy

Then go to terminal and enter following command:-

sudo easy_install pip

For Python install packages check this

Requirements for Installing Packages This section describes the steps to follow before installing other Python packages.

Install pip, setuptools, and wheel If you have Python 2 >=2.7.9 or Python 3 >=3.4 installed from python.org, you will already have pip and setuptools, but will need to upgrade to the latest version:

On Linux or OS X:

pip install -U pip setuptools On Windows:

python -m pip install -U pip setuptools If you’re using a Python install on Linux that’s managed by the system package manager (e.g “yum”, “apt-get” etc…), and you want to use the system package manager to install or upgrade pip, then see Installing pip/setuptools/wheel with Linux Package Managers

Otherwise:

Securely Download get-pip.py 1

Run python get-pip.py. 2 This will install or upgrade pip. Additionally, it will install setuptools and wheel if they’re not installed already.

0
30

I spent ages going through all the answers on this page but found the one that worked for me in the comments of the OP question by s-walsh

The answer is to use pip3:

$ pip3 install <name-of-install>
0
24

Installing using apt-get installs a system wide pip, not just a local one for your user. Try this command to get pip running on your system ...

$ sudo apt-get install python-pip python-dev build-essential

Then pip will be installed without any issues and you will be able to use sudo pip....

2
  • 9
    This won't work as your solution is for *nix when OP specifically said "This is on Mac OS X" Commented Sep 22, 2016 at 22:54
  • 4
    Debian and ubuntu are linux distributions, this question is about mac osx, not linux. Commented Jan 18, 2018 at 8:34
21

Most of the methods to install PIP are deprecated. Here is the latest (2019) solution. Please download get-pip script

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

Run the script

sudo python get-pip.py
1
  • or curl -L https://bootstrap.pypa.io/get-pip.py | sudo python
    – ivansaul
    Commented Dec 25, 2021 at 16:27
18

Latest update 2021.

In Ubuntu 20 64bit works perfectly

Installation of python3

sudo apt install python3

Pip Installation

sudo apt install python3-pip

Add following alias in $HOME/.bash_aliases in some cases file may be hidden.

alias pip="/usr/bin/python3 -m pip "

Refresh current terminal session.

. ~/.profile

  • check pip usage: pip
  • Install a package: pip install {{package_name}}

extra info

to get Home path

echo $HOME

you will get your home path.

15

To solve:

  1. Add this line to ~/.bash_profile:

    export PATH="/usr/local/bin:$PATH"
    
  2. In a terminal window, run

    source ~/.bash_profile
    
3
  • 3
    You only need to source the bash_profile if you just made fresh changes to the file in that same terminal session. When you open any new terminals from that point on, it will already have sourced the new version.
    – jdi
    Commented Mar 20, 2012 at 4:33
  • Best answer, after trying making alias, brew install python, sudo python get-pip.py is sudo easy_install pip Commented Mar 15, 2018 at 14:39
  • This obviously only works if (a) your pip is really in /usr/local/bin and (b) remarkably, /usr/local/bin wasn't already on your PATH. Obviously, if pip is in a different directory (in which case it's somewhat more likely to not be on the system-provided PATH), adapt accordingly.
    – tripleee
    Commented Dec 2, 2023 at 10:10
14

It might be the root permission. I tried exit root login, and use

sudo su -l root
pip <command>
9

install Homebrew, open Terminal or your favorite OSX terminal emulator and run

$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

insert the Homebrew directory at the top of your PATH environment variable. You can do this by adding the following line at the bottom of your ~/.profile file

export PATH=/usr/local/bin:/usr/local/sbin:$PATH

Now, we can install Python 2.7:

$ brew install python

Get pip repository:

$ git clone https://github.com/pypa/pip

install pip:

$sudo easy_install pip
1
  • Just export PATH=/usr/local/bin:/usr/local/sbin:$PATH solved the problem for me. Commented Apr 23, 2019 at 20:47
9

Python installs it by default, but if it's not installed, you can install it manually using the following command (for Linux only):

For Python 3:

sudo apt install python3-pip 

For Python 2:

sudo apt install python-pip
1
  • Again, these commands are specific to Debian-based Linux distros, which split python3 and python3-pip into separate packages for policy reasons. Other Linux systems don't have this arrangement (and don't use Apt for package management).
    – tripleee
    Commented Dec 2, 2023 at 11:57
7

If you are running Python 3.5, run the following terminal command:

sudo pip3 install -U nltk

Any other pip commands in terminal would be similar:

pip3 install --upgrade pip
sudo pip3 install -U numpy ::
7

It solved my problem by using

sudo easy_install pip
6

Solved this by upgrading python 3 brew upgrade python: Now i can just do:

pip3 install  <package>  

==> python
Python has been installed as
  /usr/local/bin/python3

Unversioned symlinks `python`, `python-config`, `pip` etc. pointing to
`python3`, `python3-config`, `pip3` etc., respectively, have 
5

Based on this stackoverflow answer and some of the answers on this thread, I have created an alias in the rc file: alias pip="python3 -m pip"

There seem to be many different answers to this question but this seems to be the best-practice approach.

4

Avoiding sudo:

python <(curl https://bootstrap.pypa.io/get-pip.py) --user
echo 'export "PATH=$HOME/Library/Python/2.7/bin:$PATH"' >> ~/.bash_profile

From:

http://www.pip-command-not-found.com

1
  • 5
    Yes… the question is specifically for macOS.
    – mxcl
    Commented Apr 2, 2018 at 14:30
4

CentOS 7 users can just use:

yum install python-pip

Also recommend using virtualenv if you're using pip. It can be added in the same way:

yum install python-virtualenv
1
  • yum install -y python-pip python3-pip Commented Sep 6, 2021 at 6:18
4

assuming you have internet see: https://pip.pypa.io/en/stable/installing/

basically run:

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

and

python get-pip.py
4

Try using this. Instead of zmq, we can use any package instead of zmq.

sudo apt-get install python3-pip
sudo apt-get update
python3 -m pip install zmq

I was was not able to install this zmq package in my docker image because of the same issue i was getting. So tried this as another way to install and it worked fine for me.

1
  • The apt-get update is not useful here. You want to run it before you apt-get install something, not after.)
    – tripleee
    Commented Dec 2, 2023 at 10:16
4

To overcome the issue bash: pip: command not found in Mac

Found two versions on Mac 1 is 2.7 and the other is 3.7

  • when I say sudo easy_install pip, pip got installed under 2.7

  • when I say sudo easy_install-3.7 pip, pip got installed under 3.7

But, whenever I would require to do pip install , I wanted to install the package under python3.7, so I have set an alias (alias pip=pip3) in .bash_profile.

so now, whenever I do pip install <package_name>, it gets installed under python3.7

2

Not sure why this wasnt mentioned before, but the only thing that worked for me (on my NVIDIA Xavier) was:

sudo apt-get install python3-pip

(or sudo apt-get install python-pip for python 2)

1
  • For Debian-based systems Commented May 9, 2019 at 16:53
2

(Context: My OS is Amazon linux using AWS. It seems similar to RedHat but it's stripped down a bit, it seems.)

Exit the shell, then open a new shell. The pip command now works.

That's what solved the problem at this location.

You might want to know as well: The pip commands to install software then needed to be written like this example (jupyter for example) to work correctly on my system:

pip install jupyter --user

Specifically, note the lack of sudo, and the presence of --user

1

What I did to overcome this was sudo apt install python-pip.

It turned out my virtual machine did not have pip installed yet. It's conceivable that other people could have this scenario too.

1
  • 1
    The -1 point is because of a typo in the command that have been edited since. This solution works in 99% of cases.
    – Nino Filiu
    Commented Aug 21, 2018 at 8:37
1

The updated command for installing pip3 is :

sudo apt-get install python3-pip
1
  • This is obviously only true for Debian and other Debian-based Linux distros.
    – tripleee
    Commented Dec 2, 2023 at 10:17
1
apt -y -qq install python3 python3-pip
ln -s /usr/bin/python3 /usr/bin/python
ln -s /usr/bin/pip3 /usr/bin/pip
1
  • You should never make manual changes to /usr/bin on systems where this location is managed by the OS or your package manager (which is to say, basically, all of them). Creating symlinks in /usr/local/bin instead should be totally fine. (That is, ln -s /usr/bin/python3 /usr/local/bin/python and similarly for pip. You want to ensure that /usr/local/bin is early on your PATH, but that should already be the case.)
    – tripleee
    Commented Dec 2, 2023 at 10:13
1

I had a similar issue. I had to uninstall and then reinstall pip3:

uninstall:

sudo apt-get remove python3-pip

reinstall:

sudo apt-get install python3-pip

Not the answer you're looking for? Browse other questions tagged or ask your own question.