I donβt know what to do with it. If I ask my shell (bash) to run python without specifying the exact path, it somehow starts the wrong program (or maybe the right program, but with the wrong dylib loading). However, the result of which python and /usr/bin/env python looks very good.
Here is an illustration of what I'm talking about:
OK, first of all, where is my python command python ? Let symbolic links follow. (BTW, Too bad readlink -f and realpath do not exist on OSX ...)
$ which python /usr/local/bin/python $ ls -l /usr/local/bin/python lrwxr-xr-x 1 root wheel 68 Jan 18 11:44 /usr/local/bin/python@ -> ../../../Library/Frameworks/Python.framework/Versions/2.7/bin/python $ ls -l /Library/Frameworks/Python.framework/Versions/2.7/bin/python lrwxr-xr-x 1 root admin 7 Jan 18 11:44 /Library/Frameworks/Python.framework/Versions/2.7/bin/python@ -> python2 $ ls -l /Library/Frameworks/Python.framework/Versions/2.7/bin/python2 lrwxr-xr-x 1 root admin 9 Jan 18 11:44 /Library/Frameworks/Python.framework/Versions/2.7/bin/python2@ -> python2.7 $ ls -l /Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7 -rwxrwxr-x 1 root admin 25624 Dec 5 15:57 /Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7*
If I call /usr/local/bin/python , where does python itself think it is? And what version?
$ /usr/local/bin/python -c "import sys; print sys.executable; print sys.version_info" /Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python sys.version_info(major=2, minor=7, micro=11, releaselevel='final', serial=0)
OK, it looks legal. Instead of typing /usr/local/bin/python , what if I let /usr/bin/env find python for me?
$ /usr/bin/env python -c "import sys; print sys.executable; print sys.version_info" /Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python sys.version_info(major=2, minor=7, micro=11, releaselevel='final', serial=0)
Same. So far no surprises. Ok, what if I just type python ? It should be the same as /usr/bin/env python , right?
$ python -c "import sys; print sys.executable; print sys.version_info" /usr/local/bin/python sys.version_info(major=2, minor=7, micro=10, releaselevel='final', serial=0)
Wait what? sys.executable points to a symbolic link , and the version is incorrect. What's happening?
Why would you print python any way from the input /usr/local/bin/python ?
BTW:
- I double-checked bash aliases, and
python not one of them. ( alias | grep python )