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!

  • 1
    What does `which python` say? And just to be paranoid, `echo $PATH` to check that `/usr/bin` is in the path. –  Aug 01 '12 at 21:15
  • cd into the python directory and search for the easy_install command, /path/to/easy_install . This is windows anyways, but it might be similar with mac. –  Aug 01 '12 at 21:16
  • Are any of the python versions actually named "python", or things like "python27" and "python32"? – arxanas Aug 01 '12 at 21:16
  • What's the output pf `ls -l /usr/bin/python*`? – ernie Aug 01 '12 at 21:22
  • @DanielFischer which python says /opt/local/bin/python –  Aug 01 '12 at 21:59
  • @ernie ls -l says only 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-config 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 -> –  Aug 01 '12 at 22:01
  • Okay, that explains why it isn't found in `/usr/bin`. Make a symlink. –  Aug 01 '12 at 22:01
  • @ernie and furthermore ../../System/Library/Frameworks/Python.framework/Versions/2.6/bin/python2.6-config but going into /usr/bin/ i can see: python python2.5 python2.7-config python3.2-config pythonw2-32 pythonw3-32 python-32 python2.5-config python3 python3.2m pythonw2.5 pythonw3.2 python-config python2.6 python3-32 python3.2m-config pythonw2.6 pythonw3.2-32 python2 python2.6-config python3-config pythonw pythonw2.7 python2-32 python2.7 python3.2 pythonw-32 pythonw2.7-32 python2-config python2.7-32 python3.2-32 pythonw2 pythonw3 –  Aug 01 '12 at 22:02
  • @DanielFischer a symlink like: ln -s /opt/local/bin/python2.7 /usr/bin/python ? –  Aug 01 '12 at 22:08
  • If that's what `/opt/local/bin/python` points to, that's okay. –  Aug 01 '12 at 22:10
  • Thank you very much for your help! Now everything is much more understandable! –  Aug 02 '12 at 11:29

3 Answers3

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

ernie
  • 6,293
  • 2
  • 28
  • 30
  • Thank you very much for your help! Now everything is much more understandable! –  Aug 02 '12 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

  • 1
    `python3` might be more preferable for python3.2. `python` should be reserve for Python 2 – jfs Aug 01 '12 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 –  Aug 01 '12 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