629

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.

starball
  • 20,030
  • 7
  • 43
  • 238
Trindaz
  • 17,029
  • 21
  • 82
  • 111
  • Did the installation of pip report it was successful? – jdi Mar 20 '12 at 02:48
  • Perhaps you need to run the command as root? – John La Rooy Mar 20 '12 at 02:50
  • I am running terminal using sudo, so everything should be run as root. The installed did report success. – Trindaz Mar 20 '12 at 02:52
  • 77
    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 Feb 28 '19 at 00:59
  • 1
    pip 3 work for me. Ex: pip3 install APScheduler – Dan Oct 11 '19 at 02:28
  • 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. – Karl Knechtel Jan 12 '22 at 07:37
  • @SWalsh The question specifically mentions using Python 2.7, so a python3 solution doesn't help users who are using Python 2.7. – Josh Correia Feb 25 '22 at 09:44
  • @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. – starball Dec 06 '22 at 21:16

39 Answers39

565

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

dda
  • 6,030
  • 2
  • 25
  • 34
klobucar
  • 6,307
  • 1
  • 13
  • 15
475

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.

cidermole
  • 5,662
  • 1
  • 15
  • 21
358

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.

Per Quested Aronsson
  • 11,380
  • 8
  • 54
  • 76
66

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.

jdi
  • 90,542
  • 19
  • 167
  • 203
  • 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 Mar 20 '12 at 03: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 Mar 20 '12 at 03:30
  • There is no file .profile in ~/ but there is a .bash_profile. Are they the same? – Trindaz Mar 20 '12 at 03:44
  • 1
    macos: ln -s ~/Library/Python/2.7/bin/pip /usr/local/bin/pip – Kesha Antonov Jun 11 '19 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 Jun 12 '19 at 10:30
  • @jdi You suggested in your answer to do "ln". Isn't it safe? – Kesha Antonov Jun 12 '19 at 17:57
  • @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. – jdi Jun 13 '19 at 19:54
  • @jdi Ahh... I got it. Thanks for the explanation! Yep, I think you're right. – Kesha Antonov Jun 14 '19 at 07:30
54

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.

desertnaut
  • 57,590
  • 26
  • 140
  • 166
ness-EE
  • 1,334
  • 13
  • 19
44

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

Jun
  • 2,942
  • 5
  • 28
  • 50
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.

Ashish P
  • 1,463
  • 1
  • 20
  • 29
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>
cfranklin
  • 1,500
  • 1
  • 13
  • 14
23

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...".

Mubashar Abbas
  • 5,536
  • 4
  • 38
  • 49
Vignesh
  • 1,521
  • 1
  • 12
  • 11
20

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
mixdev
  • 2,724
  • 2
  • 30
  • 25
17

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.

dipenparmar12
  • 3,042
  • 1
  • 29
  • 39
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
    
desertnaut
  • 57,590
  • 26
  • 140
  • 166
Trindaz
  • 17,029
  • 21
  • 82
  • 111
  • 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 Mar 20 '12 at 04:33
  • Best answer, after trying making alias, brew install python, sudo python get-pip.py is sudo easy_install pip – Oleksii Kyslytsyn Mar 15 '18 at 14:39
14

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

sudo su -l root
pip <command>
desertnaut
  • 57,590
  • 26
  • 140
  • 166
Jay0Lu
  • 318
  • 2
  • 8
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
Aden Yee
  • 99
  • 1
  • 1
8

python install it by default but if not install you can install it manual use following cmd (for linux only )

for python3 :

sudo apt install python3-pip 

for python2

sudo apt install python-pip 

hope its help.

Krishna Jangid
  • 4,961
  • 5
  • 27
  • 33
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 ::
Gandhi
  • 11,875
  • 4
  • 39
  • 63
Eric Pierre
  • 99
  • 1
  • 4
7

It solved my problem by using

sudo easy_install pip
desertnaut
  • 57,590
  • 26
  • 140
  • 166
BlueJapan
  • 1,286
  • 2
  • 15
  • 16
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 
blackchestnut
  • 1,259
  • 10
  • 15
z atef
  • 7,138
  • 3
  • 55
  • 50
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.

papiro
  • 2,158
  • 1
  • 20
  • 29
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

mxcl
  • 26,392
  • 12
  • 99
  • 98
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
Felipe
  • 10,606
  • 5
  • 40
  • 57
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
Nahshon paz
  • 4,005
  • 2
  • 21
  • 32
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

desertnaut
  • 57,590
  • 26
  • 140
  • 166
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.

Bipin B
  • 152
  • 9
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

Would be real nice if pip docs had said anything about all this, but that would take typing in more characters I guess.

Geoffrey Anderson
  • 1,534
  • 17
  • 25
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)

DankMasterDan
  • 1,900
  • 4
  • 23
  • 35
2
apt -y -qq install python3 python3-pip
ln -s /usr/bin/python3 /usr/bin/python
ln -s /usr/bin/pip3 /usr/bin/pip
lockwise
  • 53
  • 1
  • 5
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.

Nino Filiu
  • 16,660
  • 11
  • 54
  • 84
Connor
  • 4,216
  • 2
  • 29
  • 40
  • 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 Aug 21 '18 at 08:37
1

The updated command for installing pip3 is :

sudo apt-get install python3-pip
exploitr
  • 843
  • 1
  • 14
  • 27
repleeka
  • 550
  • 5
  • 14
1

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

Voontent
  • 719
  • 5
  • 8
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

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
pushd93
  • 335
  • 4
  • 10
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.

Wenfang Du
  • 8,804
  • 9
  • 59
  • 90
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
rmisegal
  • 77
  • 1
0

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

uninstall:

sudo apt-get remove python3-pip

reinstall:

sudo apt-get install python3-pip

This work for me :)

Mohamed Raafat
  • 122
  • 1
  • 5
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
Sienna
  • 1,570
  • 3
  • 24
  • 48
jingwenxxx
  • 31
  • 3
0

For Fedora users:

sudo dnf install python3-pip

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

Ilko
  • 1,288
  • 1
  • 14
  • 19
-1

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"

Nihi Gabriel
  • 129
  • 1
  • 3
-2

Instead of pip install -r requirements.txt use

pip3 install -r requirements.txt

Victorhez
  • 7
  • 1
  • 3