Skip to content Skip to sidebar Skip to footer

Homebrew Python 2.7 Vs Os X Python 2.7

this is my first time asking a question here so sorry in advance if I'm doing something wrong. The problem is I installed python 2 using Homebrew to avoid using OS X system python

Solution 1:

Homebrew recently changed the way it handles Python 2.x vs 3.x. It no longer shadows macOS’s python by default and instead installs Python 2.x as python2 and Python 3.x as python3.

In fact, it does install python but doesn’t symlink it in /usr/local/bin, hence why your shell can’t find it. If you wish to get everything working as before you need to add it to your $PATH:

export PATH="$(brew --prefix python)/libexec/bin:$PATH"

You could also add an alias from python to python2 and from pip to pip2 but it’s a worse solution because you need one alias for each executable.

# in your ~/.bash_profilealias python=python2
alias pip=pip2

Then start a new terminal session for the changes to take effect.

See the official documentation for more info. This is also outlined in brew info python:

$ brew info python
python: stable 2.7.13, HEAD
...
==> 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 ~/.bash_profile:
  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
...

Solution 2:

Just go download and install new version any version of Python 2 or 3 for Mac

and make sure you in the correct local (home) directory looks like

compname:~ yourname$

Post a Comment for "Homebrew Python 2.7 Vs Os X Python 2.7"