Homebrew-core: Python 'pip' command not found

Created on 23 Aug 2016  路  7Comments  路  Source: Homebrew/homebrew-core

If Homebrew was updated on Aug 10-11th 2016 and brew update always says Already up-to-date. you need to run: cd $(brew --repo); git fetch; git reset --hard origin/master; brew update.

Please follow the general troubleshooting steps first:

  • [x] Ran brew update and retried your prior step?
  • [x] Ran brew doctor, fixed as many issues as possible and retried your prior step?
  • [x] If you're seeing permission errors tried running sudo chown -R $(whoami) $(brew --prefix)?

    Bug reports:

Link to brew config and brew doctor output:
https://gist.github.com/anonymous/5f177f54f2c3e50982c587d3350d8384

I have Python 2.7 and Python 3.5 installed via Brew, which I understand should have installed 'pip' as well. However, running pip returns a "command not found error":

$ pip
-bash: pip: command not found

I do have the pip located in the Python 2.7 and 3.5 directories as shown below:

$ sudo find / -name pip
Password:

/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/bin/pip
/usr/local/Cellar/python/2.7.12/libexec/pip
/usr/local/Cellar/python/2.7.12/libexec/pip/build/lib/pip
/usr/local/Cellar/python/2.7.12/libexec/pip/pip
/usr/local/Cellar/python3/3.5.2_1/Frameworks/Python.framework/Versions/3.5/bin/pip
/usr/local/Cellar/python3/3.5.2_1/Frameworks/Python.framework/Versions/3.5/share/doc/python3.5/examples/Tools/msi/pip
/usr/local/Cellar/python3/3.5.2_1/libexec/pip
/usr/local/Cellar/python3/3.5.2_1/libexec/pip/build/lib/pip
/usr/local/Cellar/python3/3.5.2_1/libexec/pip/pip
/usr/local/lib/python2.7/site-packages/pip
/usr/local/lib/python3.5/site-packages/pip
/usr/local/lib/python3.5/site-packages/pip-8.1.2-py3.5.egg/pip

I can pip directly from those directories or via $ python -m pip or $ python3 -m pip.

Before adding pip to my PATH variable, I wanted to be sure there wasn't a problem with the way Python or pip was installed via Brew.

python

Most helpful comment

What happens when you run brew postinstall python or brew postinstall python3?

All 7 comments

CC @tdsmith for pip thoughts as I'm not sure what's going on here.

What happens when you run brew postinstall python or brew postinstall python3?

That seems to have done the trick. What does the "postinstall" command do?

$ brew postinstall python
==> Using the sandbox
==> /usr/local/Cellar/python/2.7.12/bin/python -s setup.py --no-user-cfg install --force --verbose --single-version-externally-managed --record=installed.txt --install-scripts=/u
==> /usr/local/Cellar/python/2.7.12/bin/python -s setup.py --no-user-cfg install --force --verbose --single-version-externally-managed --record=installed.txt --install-scripts=/u
==> /usr/local/Cellar/python/2.7.12/bin/python -s setup.py --no-user-cfg install --force --verbose --single-version-externally-managed --record=installed.txt --install-scripts=/u

$ brew postinstall python3
==> Using the sandbox
==> /usr/local/Cellar/python3/3.5.2_1/bin/python3 -s setup.py --no-user-cfg install --force --verbose --install-scripts=/usr/local/Cellar/python3/3.5.2_1/bin --install-lib=/usr/l
==> /usr/local/Cellar/python3/3.5.2_1/bin/python3 -s setup.py --no-user-cfg install --force --verbose --install-scripts=/usr/local/Cellar/python3/3.5.2_1/bin --install-lib=/usr/l
==> /usr/local/Cellar/python3/3.5.2_1/bin/python3 -s setup.py --no-user-cfg install --force --verbose --install-scripts=/usr/local/Cellar/python3/3.5.2_1/bin --install-lib=/usr/l

$ pip -h

Usage:
pip [options]

Commands:
install Install packages.
download Download packages.
<...snip...>

$ pip3 -h

Usage:
pip [options]

Commands:
install Install packages.
download Download packages.
<...snip...>

That also fixed the problem I was having where if I installed a Python package using '$python -m pip install ', the new package name would not be a recognized command without specifying it's path.

Thanks for such a quick turnaround, guys.

This did not work for me. It also appears that install is misspelled.

$ brew postinstall python
==> Postinstalling python
==> /usr/local/Cellar/python/2.7.14/bin/python2 -s setup.py --no-user-cfg instal
==> /usr/local/Cellar/python/2.7.14/bin/python2 -s setup.py --no-user-cfg instal
==> /usr/local/Cellar/python/2.7.14/bin/python2 -s setup.py --no-user-cfg instal

$ brew postinstall python3
==> Postinstalling python3
==> /usr/local/Cellar/python3/3.6.4/bin/python3 -s setup.py --no-user-cfg instal
==> /usr/local/Cellar/python3/3.6.4/bin/python3 -s setup.py --no-user-cfg instal
==> /usr/local/Cellar/python3/3.6.4/bin/python3 -s setup.py --no-user-cfg instal

@philip550c I ran into this issue as well. Here's what solved it for me:
sudo chown $(whoami):staff -R /usr/local/lib/Python2.7 && brew unlink python && brew link python

Along with the command above I also had to run the following to clean up an old run of sudo pip that had created files in /usr/local/bin.

sudo chown -R $(whoami):staff /usr/local/bin/{py*,*.py,*.pyc}
Was this page helpful?
0 / 5 - 0 ratings

Related issues

Steffen911 picture Steffen911  路  3Comments

jakepetroules picture jakepetroules  路  3Comments

sstadick picture sstadick  路  4Comments

dredmorbius picture dredmorbius  路  3Comments

BluePawDev picture BluePawDev  路  3Comments