Why am I getting command not found even though path to command exists in PATH variable?

On Mac OSX 10.10.1 I get command not found for anything installed in /usr/local/bin (however command is found if I use sudo) PATH variable contains this path. for example pip. Here are some lines from terminal:


Dylans-MacBook-Air:edX Dylan$ echo $PATH/Library/Frameworks/Python.framework/Versions/3.4/bin:/Library/Frameworks/Python.framework/Versions/3.4/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin  
Dylans-MacBook-Air:edX Dylan$ ls /usr/local/bin  
2to3            idle3.4         pydoc3          python3.4-32        rtmpdump        tclsh8.5        wish8.5
2to3-3.4        pip         pydoc3.4        python3.4-config    rtmpgw          tclsh8.6        wish8.6
easy_install        pip2            python3         python3.4m      rtmpsrv         tclvfse         youtube-dl
easy_install-2.7    pip2.7          python3-32      python3.4m-config   rtmpsuck        teacup
easy_install-3.4    pip3            python3-config      pyvenv          tclselect       udemy-dl
idle3           pip3.4          python3.4       pyvenv-3.4      tclsh           wish
Dylans-MacBook-Air:edX Dylan$ pip
-bash: pip: command not found
Dylans-MacBook-Air:edX Dylan$ which pip
Dylans-MacBook-Air:edX Dylan$ sudo which pip
/usr/local/bin/pip
Dylans-MacBook-Air:edX Dylan$ 

What could be causing this behaviour and how do I fix it?


The fix I ended up was removing all home brew Python and fixing up the system Python.

brew remove python
brew remove python3
brew cleanup

Check for the system pip and python (or absence of pip is OK too).

which python
which pip
which pip3
which python3

At this point, you need to easy_install a system based pip:

sudo easy_install --upgrade pip
pip --version

You should now have a pip that's based on /Library/Python (and pip 7.1.2 against python 2.7 for El Capitan in October 2015)

mac:~ me$ pip --version
pip 7.1.2 from /Library/Python/2.7/site-packages/pip-7.1.2-py2.7.egg (python 2.7)
mac:~ me$ which pip
/usr/local/bin/pip
mac:~ me$ which python
/usr/bin/python