Homebrew-core: python formula does not link to /usr/local/bin/python

Created on 30 Jul 2017  路  5Comments  路  Source: Homebrew/homebrew-core

Please always follow these steps:

Please note we will close your issue without comment if you delete or do not fill out the issue checklist and provide ALL the requested information.

To help us debug your issue please explain:

What you were trying to do (and why)

After a recent brew upgrade, the Python virtualenvwrapper.sh started giving errors. It said python cannot find virtualenvwrapper module. I was trying to fix this error message.

What happened (include command output)

Then I did a bit debugging and realized it started using the macOS system python (/usr/bin/python) after a while. No matter how many times I reinstalled python formula, I still did not get a /usr/local/bin/python symlink:

$ brew unlink python && brew link python -v
Unlinking /usr/local/Cellar/python/2.7.13_1... 32 symlinks removed
Linking /usr/local/Cellar/python/2.7.13_1...
ln -s ../Cellar/python/2.7.13_1/bin/2to3-2 2to3-2
ln -s ../Cellar/python/2.7.13_1/bin/2to3-2.7 2to3-2.7
ln -s ../Cellar/python/2.7.13_1/bin/easy_install easy_install
ln -s ../Cellar/python/2.7.13_1/bin/easy_install-2.7 easy_install-2.7
ln -s ../Cellar/python/2.7.13_1/bin/idle2 idle2
ln -s ../Cellar/python/2.7.13_1/bin/idle2.7 idle2.7
ln -s ../Cellar/python/2.7.13_1/bin/pip pip
ln -s ../Cellar/python/2.7.13_1/bin/pip2 pip2
ln -s ../Cellar/python/2.7.13_1/bin/pip2.7 pip2.7
ln -s ../Cellar/python/2.7.13_1/bin/pydoc2 pydoc2
ln -s ../Cellar/python/2.7.13_1/bin/pydoc2.7 pydoc2.7
ln -s ../Cellar/python/2.7.13_1/bin/python2 python2
ln -s ../Cellar/python/2.7.13_1/bin/python2-config python2-config
ln -s ../Cellar/python/2.7.13_1/bin/python2.7 python2.7
ln -s ../Cellar/python/2.7.13_1/bin/python2.7-config python2.7-config
ln -s ../Cellar/python/2.7.13_1/bin/pythonw2 pythonw2
ln -s ../Cellar/python/2.7.13_1/bin/pythonw2.7 pythonw2.7
ln -s ../Cellar/python/2.7.13_1/bin/smtpd2.7.py smtpd2.7.py
ln -s ../Cellar/python/2.7.13_1/bin/smtpd2.py smtpd2.py
ln -s ../Cellar/python/2.7.13_1/bin/wheel wheel
ln -s ../../../Cellar/python/2.7.13_1/share/man/man1/python.1 python.1
ln -s ../../../Cellar/python/2.7.13_1/share/man/man1/python2.1 python2.1
ln -s ../../../Cellar/python/2.7.13_1/share/man/man1/python2.7.1 python2.7.1
ln -s ../Cellar/python/2.7.13_1/share/python python
ln -s ../../Cellar/python/2.7.13_1/lib/pkgconfig/python-2.7.pc python-2.7.pc
ln -s ../../Cellar/python/2.7.13_1/lib/pkgconfig/python.pc python.pc
ln -s ../../Cellar/python/2.7.13_1/lib/pkgconfig/python2.pc python2.pc
ln -s ../../Cellar/python/2.7.13_1/Frameworks/Python.framework/Headers Headers
ln -s ../../Cellar/python/2.7.13_1/Frameworks/Python.framework/Python Python
ln -s ../../Cellar/python/2.7.13_1/Frameworks/Python.framework/Resources Resources
ln -s ../../../Cellar/python/2.7.13_1/Frameworks/Python.framework/Versions/2.7 2.7
ln -s ../../../Cellar/python/2.7.13_1/Frameworks/Python.framework/Versions/Current Current
32 symlinks created

What you expected to happen

To have a symlink at /usr/local/bin/python after installing python formula so that it replaces my system Python.

Step-by-step reproduction instructions (by running brew install commands)

  • brew install python
  • stat /usr/local/bin/python → does not exist.

Most helpful comment

Also the caveats at the end of the python installation:

==> Caveats
This formula installs a python2 executable to /usr/local/bin.
If you wish to have this formula's python executable in your PATH then add
the following to ~/.zshrc:
  export PATH="/usr/local/opt/python/libexec/bin:$PATH"

Pip and setuptools have been installed. To update them
  pip2 install --upgrade pip setuptools

You can install Python packages with
  pip2 install <package>

They will install into the site-package directory
  /usr/local/lib/python2.7/site-packages

See: http://docs.brew.sh/Homebrew-and-Python.html

All 5 comments

See https://github.com/Homebrew/homebrew-core/pull/14408 & the significant discussion there.

Also the caveats at the end of the python installation:

==> Caveats
This formula installs a python2 executable to /usr/local/bin.
If you wish to have this formula's python executable in your PATH then add
the following to ~/.zshrc:
  export PATH="/usr/local/opt/python/libexec/bin:$PATH"

Pip and setuptools have been installed. To update them
  pip2 install --upgrade pip setuptools

You can install Python packages with
  pip2 install <package>

They will install into the site-package directory
  /usr/local/lib/python2.7/site-packages

See: http://docs.brew.sh/Homebrew-and-Python.html

I am still having this issue.
After installing python with brew, there is no symlink /usr/local/bin/python

@marisveide python@2 creates /usr/local/bin/python. python creates /usr/local/bin/python3.

Thanks, @ilovezfs!
I ended up creating symbolic links for python and pip manyally.

Was this page helpful?
0 / 5 - 0 ratings