bash: pip: command not found
Asked Answered
H

39

648

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.

Hullda answered 20/3, 2012 at 2:43 Comment(8)
Did the installation of pip report it was successful?Vardon
Perhaps you need to run the command as root?Exemplar
I am running terminal using sudo, so everything should be run as root. The installed did report success.Hullda
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.Minni
pip 3 work for me. Ex: pip3 install APSchedulerLindberg
I’m voting to close this question because it is almost ten years old and is specific to a completely obsolete version of Python. As asked, it can only serve to mislead newcomers - since if pip is missing from an up-to-date installation then most of the answers here are at best nonsensical and at worst actively harmful.Aerobiosis
@SWalsh The question specifically mentions using Python 2.7, so a python3 solution doesn't help users who are using Python 2.7.Manassas
@KarlKnechtel how about editing the body instead with a warning label near the top if you believe so firmly? I don't know Python well myself.Spermatophore
M
567

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. :)

Militarist answered 20/3, 2012 at 5:27 Comment(7)
Thanks for the suggestion, sorry but I'm a newbie sudo: easy_install: command not foundItalianate
TabError: inconsistent use of tabs and spaces in indentation (python 3.4)Vania
The link that @PaigeLo posted seems to lead to a random page that made my Safari freeze...would not recommend doing thatNecessitate
sudo apt install python-pip?Jahdiel
This assumes you have easy_install installed. How is this an answer?Certie
Easy Install is deprecated. Do not use it. Instead use pip. - setuptools.readthedocs.io/en/latest/deprecated/…Gallfly
How do you use pip to install pip?Dennet
G
495

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.

Gran answered 10/8, 2013 at 20:34 Comment(5)
for pip3: sudo apt-get install python3-setuptools & sudo easy_install3 pipLuscious
this is the right answer sudo apt-get install python-setuptools followed by sudo easy_install pipRealize
@Smily But the question states explicitly that this is for macOS, not UbuntuJotting
@SriHarshaChilakapati you are right and this answer seems more related: https://mcmap.net/q/65029/-how-to-install-pip-for-python-3-on-mac-os-xChoi
after installing pytho3-setuptools, i have a command not found trying to execute easy_install3Crowson
N
375

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.

Neomaneomah answered 13/10, 2017 at 8:13 Comment(4)
All those who installed ubuntu 16 should try this first.Homburg
Worked for me on macOS after brew install python.Bollay
That was exactly my case. Installed Python from .pkg file.Noelianoell
And you can use pip2 if you are using Python 2.xQuadrate
V
67

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.

Vardon answered 20/3, 2012 at 2:51 Comment(8)
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?Hullda
The system version may be here /System/Library/Frameworks/Python.framework/Versions/2.6/bin. And ~/ is your home directory with the hidden file .profileVardon
There is no file .profile in ~/ but there is a .bash_profile. Are they the same?Hullda
macos: ln -s ~/Library/Python/2.7/bin/pip /usr/local/bin/pipWhitworth
@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.Vardon
@Vardon You suggested in your answer to do "ln". Isn't it safe?Whitworth
@Kesha Antonov I didn't mean that using a symlink at all is bad. Yes my examples show symlinks but they are from system locations that are available to any user of the machine. My argument is that you suggested to link from a single user's home directory install of python into a system location. That means there could be the potential for breakage of another user of the system. While you may only have a system with one user, your suggestion won't always work for everyone.Vardon
@Vardon Ahh... I got it. Thanks for the explanation! Yep, I think you're right.Whitworth
S
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.

Schatz answered 1/11, 2014 at 10:5 Comment(0)
B
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

Blistery answered 26/8, 2019 at 23:52 Comment(1)
Or curl -L get-pip.io | sudo python.Abohm
A
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.

Astrology answered 28/6, 2017 at 4:45 Comment(0)
C
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>
Chayachayote answered 26/12, 2019 at 23:30 Comment(0)
B
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....

Beefy answered 11/8, 2016 at 6:16 Comment(2)
This won't work as your solution is for *nix when OP specifically said "This is on Mac OS X"Vervain
Debian and ubuntu are linux distributions, this question is about mac osx, not linux.Zenaidazenana
S
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
Sanjay answered 2/5, 2019 at 10:2 Comment(1)
or curl -L https://bootstrap.pypa.io/get-pip.py | sudo pythonPenick
D
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.

Deuteranope answered 20/10, 2020 at 3:12 Comment(0)
H
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
    
Hullda answered 20/3, 2012 at 4:14 Comment(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.Vardon
Best answer, after trying making alias, brew install python, sudo python get-pip.py is sudo easy_install pipIncoherent
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.Dorolice
K
14

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

sudo su -l root
pip <command>
Karnak answered 13/8, 2015 at 16:4 Comment(0)
S
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
Scholastic answered 19/7, 2016 at 15:34 Comment(1)
Just export PATH=/usr/local/bin:/usr/local/sbin:$PATH solved the problem for me.Scuttlebutt
B
8

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
Briquet answered 5/8, 2019 at 10:15 Comment(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).Dorolice
S
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 ::
Secondbest answered 6/5, 2016 at 6:31 Comment(0)
B
7

It solved my problem by using

sudo easy_install pip
Bonar answered 15/6, 2020 at 1:19 Comment(0)
B
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 
Buntline answered 27/7, 2019 at 17:21 Comment(0)
S
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.

Smattering answered 31/8, 2020 at 16:34 Comment(0)
M
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

Mincemeat answered 23/1, 2018 at 15:47 Comment(1)
Yes… the question is specifically for macOS.Mincemeat
P
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
Philia answered 19/10, 2018 at 17:28 Comment(1)
yum install -y python-pip python3-pipUnsure
B
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
Behlke answered 17/2, 2020 at 13:35 Comment(0)
C
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

Citrange answered 15/3, 2020 at 20:50 Comment(0)
G
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.

Glib answered 16/10, 2020 at 5:47 Comment(1)
The apt-get update is not useful here. You want to run it before you apt-get install something, not after.)Dorolice
C
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

Calix answered 6/11, 2016 at 14:10 Comment(0)
V
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)

Viscid answered 1/2, 2019 at 0:32 Comment(1)
For Debian-based systemsMetaphrast
K
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.

Kwon answered 13/7, 2018 at 1:14 Comment(1)
The -1 point is because of a typo in the command that have been edited since. This solution works in 99% of cases.Subsequence
P
1

The updated command for installing pip3 is :

sudo apt-get install python3-pip
Posture answered 27/4, 2020 at 19:16 Comment(1)
This is obviously only true for Debian and other Debian-based Linux distros.Dorolice
P
1
apt -y -qq install python3 python3-pip
ln -s /usr/bin/python3 /usr/bin/python
ln -s /usr/bin/pip3 /usr/bin/pip
Puerperal answered 17/11, 2020 at 16:26 Comment(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.)Dorolice
T
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
Tarpaulin answered 4/2, 2022 at 19:59 Comment(0)
E
0

python-pip use obsolete version of pip (9.0) current post pip version is (18.0) after updating pip edit /usr/bin/pip replace this import:

from pip import main

to

from pip._internal import main

this working for pip 18.0 problem is pip change main function name repeat for /usr/bin/pip3 and /usr/bin/pip2

also view /usr/local/lib/[your_python_version]/dist-packages/pip/__main__.py It should be the same as /usr/bin/pip

Embus answered 21/8, 2018 at 15:25 Comment(0)
P
0

Do following:

sudo apt update
sudo apt install python3-pip
source ~/.bashrc

This will surely install pip with all its dependencies. PS this is for python 3 if you want for python 2 replace python3 from the second command to python

sudo apt install python-pip
Podesta answered 8/10, 2018 at 16:37 Comment(0)
V
0

The problem seems that your python version and the library yoıu want to install is not matching versionally. Ex: If Django is Django3 and your python version is 2.7, you may get this error.

After installing is running 'python' still ran Python 2.6 and PATH was not updated
  1. Install latest version of Python
  2. Change your PATH manually as python38 and compare them.
  3. Try to reinstall

I solved this problem as replacing PATH manually with the latest version of Python. As for Windows: ;C:\python38\Scripts

Vaas answered 30/5, 2020 at 5:25 Comment(0)
P
0

If on Windows and using the Python installer, make sure to check the "Add Python to environment variables" option.

After installation, restart your shell and retry to see if pip exists.

Pianola answered 27/9, 2021 at 4:2 Comment(0)
T
0

Follow these steps to install and use the pip command in the UBUNTU terminal APP in Windows (">>" stand for UBUNTU prompt):

>>python3 --version 
             Python 3.6.7
>>sudo apt-get install python-setuptools
>>sudo apt-get update
>>sudo apt-get install python3-pip
>>python3 -m pip install pandas
Treasurehouse answered 12/1, 2022 at 7:29 Comment(0)
L
0

If you want to install pip2 when you already have pip3:

# get the installer script
curl https://bootstrap.pypa.io/pip/2.7/get-pip.py -o get-pip.py

# install pip
python get-pip.py
Lilt answered 23/2, 2022 at 1:39 Comment(0)
P
0

For Fedora users:

sudo dnf install python3-pip

Other Fedora and Python related tools, read from: Fedora developer

Precognition answered 17/10, 2022 at 11:58 Comment(0)
K
0
  1. Check if Python is Installed: Pip is bundled with Python versions 2.7.9+ and 3.4+. Open a terminal and type python --version or python3 --version to verify Python's installation. If Python is not installed, you must install it first.

  2. python3 -m pip install <library>

Kendo answered 14/3 at 12:28 Comment(0)
R
-2

for new users who are yet to activate the venv for aws cli try this out

source venv/scripts/activate

then try to

pip install awscli
Resinoid answered 28/10, 2022 at 21:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.