3

System: Mountain Lion 10.8.

I tried to uninstall python 2.7 and therefore i also deleted /usr/bin/python. However, after that i needed python again and i installed in again. Now I want to use easy_install to install matlibplot etc.. Unfortunately, it says:

-bash: /usr/bin/easy_install: /usr/bin/python: bad interpreter: No such file or directory

and also /usr/bin/python:

-bash: /usr/bin/python: No such file or directory

however if i go to /usr/bin/ there are all version of python.

I also took a look to /usr/bin/easy_install; the first line says:

#!/usr/bin/python   

BTW: i also installed python 3.2 and it also not "visible" outside /usr/bin

Do I need to fix any path variables?

Thanks for your help!

11
  • 1
    What does which python say? And just to be paranoid, echo $PATH to check that /usr/bin is in the path.
    – Daniel Fischer
    Aug 1, 2012 at 21:15
  • cd into the python directory and search for the easy_install command, /path/to/easy_install <module>. This is windows anyways, but it might be similar with mac.
    – user1538709
    Aug 1, 2012 at 21:16
  • Are any of the python versions actually named "python", or things like "python27" and "python32"?
    – arxanas
    Aug 1, 2012 at 21:16
  • What's the output pf ls -l /usr/bin/python*?
    – ernie
    Aug 1, 2012 at 21:22
  • @DanielFischer which python says /opt/local/bin/python
    – user1569756
    Aug 1, 2012 at 21:59

3 Answers 3

2

As you mentioned in the comment, ls -l /usb/bin/python* shows:

 lrwxr-xr-x 1 root wheel 75 28 Jul 16:27 /usr/bin/python2.5 -> ../../System/Library/Frameworks/Python.framework/Versions/2.5/bin/python2.5 
 lrwxr-xr-x 1 root wheel 82 28 Jul 16:27 /usr/bin/python2.5-config -> ../../System/Library/Frameworks/Python.framework/Versions/2.5/bin/python2.5-conf??ig 
 lrwxr-xr-x 1 root wheel 75 28 Jul 16:27 /usr/bin/python2.6 -> ../../System/Library/Frameworks/Python.framework/Versions/2.6/bin/python2.6 
 lrwxr-xr-x 1 root wheel 82 28 Jul 16:27 /usr/bin/python2.6-config

Note that there is no /usr/bin/python.

As @Wouter mentioned, you'll want to create a symlink:

ln -s /usr/bin/python2.6 /usr/bin/python

That'll create a symlink (think of it as a shortcut in Windows), from /usr/bin/python to /usr/bin/python2.6

For a bit more detail, you mention the first line of /usr/bin/easy_install is :

#!/usr/bin/python   

This is commonly known as the shebang line, and tells the script which interpretor to use - in this case it's trying to use /usr/bin/python, which, as we've seen from the ls command, does not exist, which is why we create a symlink

1
  • Thank you very much for your help! Now everything is much more understandable!
    – user1569756
    Aug 2, 2012 at 11:27
1

Probably a missing symlink. Try:

ln -s /usr/bin/python3.2 /usr/bin/python

You might need to replace the first argument to match the name of the python executable you found in /usr/bin

2
  • 1
    python3 might be more preferable for python3.2. python should be reserve for Python 2
    – jfs
    Aug 1, 2012 at 21:20
  • Thanks for the feedback. Then the code above should be changed to symlink to a python 2.* to make the shebang work in easy_install
    – Wouter
    Aug 1, 2012 at 21:22
0

export PATH=/usr/local/bin:/usr/local/sbin:${PATH}

should fix it. Source: https://medium.com/faun/the-right-way-to-set-up-python-on-your-mac-e923ffe8cf8e

You must log in to answer this question.