I don't know what to make of this. If I ask my shell (bash) to launch python
without giving it an exact path, it somehow launches the wrong program (or possibly the right program, but with the wrong dylib
s loaded). Yet, the output of which python
and /usr/bin/env python
both look just fine.
Here's an illustration of what I'm talking about:
OK, first of all, where is my python
command coming from? Let's follow the symlinks. (BTW, Too bad readlink -f
and realpath
don't 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 located? And what version is it?
$ /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, looks legit. Instead of typing /usr/local/bin/python
, what if I let /usr/bin/env
locate 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 thing. No surprises so far. OK, what if I just type python
? That 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 the symlink, and the version is wrong. What's going on?
Why would typing python
be different in any way from typing /usr/local/bin/python
?
BTW:
- I double-checked my bash aliases, and
python
is not one of them. (alias | grep python
)