vaichidrewar vaichidrewar - 20 days ago 6
Python Question

bash: /usr/local/bin/fab: /usr/local/opt/python/bin/python2.7: bad interpreter: No such file or directory

Fabric is not working for me. I get the following error when I run fabric.

fab realm:prod role:tools,1 build
bash: /usr/local/bin/fab: /usr/local/opt/python/bin/python2.7: bad interpreter: No such file or directory


It used to work before. But I am not sure what really changed.
I had run the below commands

brew doctor
brew install git


I don't know how those brew commands could mess with my python version

$ which python
/usr/local/bin/python
$ ls -l /usr/local/bin/python
lrwxr-xr-x 1 vaibhav.chidrewar admin 68 Nov 8 2014 /usr/local/bin/python -> ../../../Library/Frameworks/Python.framework/Versions/2.7/bin/python
$ which pip
/usr/local/bin/pip
$ which fab
/usr/local/bin/fab
$ head -n1 /usr/local/bin/pip
#!/usr/bin/python

$echo $PATH
/usr/local/lib/cw:/usr/local/bin:/Users/vaibhav.chidrewar/bin:/usr/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin


I tried uninstalling and reinstalling pip and fabric. But even after that I get the same error.

$ sudo easy_install pip
Searching for pip
Best match: pip 1.5.6
Processing pip-1.5.6-py2.7.egg
pip 1.5.6 is already the active version in easy-install.pth
Installing pip script to /usr/local/bin
Installing pip2.7 script to /usr/local/bin
Installing pip2 script to /usr/local/bin

Using /Users/vaibhav.chidrewar/Library/Python/2.7/site-packages/pip-1.5.6-py2.7.egg
Processing dependencies for pip
Finished processing dependencies for pip


$ sudo pip install fabric
Downloading/unpacking fabric
Downloading Fabric-1.12.0-py2-none-any.whl (92kB): 92kB downloaded
Requirement already satisfied (use --upgrade to upgrade): paramiko>=1.10,<2.0 in ./Library/Python/2.7/lib/python/site-packages (from fabric)
Installing collected packages: fabric
Successfully installed fabric
Cleaning up...


After that I tried install Flask and it worked.
So not sure whats wrong with Fabric.

Answer

I found that my .bash_profile was not getting sourced. So following was missing.

export PATH="/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}"

For now I copied the contents of .bash_profile to .bashrc and things are working fine again

Comments