Standardized python binary location?
On a native Mac OS X
install, I see Python
binary at /usr/bin
at version 2.6
Recently I installed Python 2.7.2
from the official binaries and it installed it at /usr/local/bin
What path of the Python
interpreter should I give in my #!
which will be standardized across all platforms?
I am开发者_开发问答 assuming it could be /usr/bin
so that I may have to symlink /usr/bin/python
to /usr/local/bin/python
but I just wanted to sure before I do this
Nope. You would use env
to find the python
executable in $PATH
and run it as appropriate.
#!/usr/bin/env python
print 'Hi mom!'
On Mac OS X, do not modify anything in /usr
(including /usr/bin
) other than /usr/local
, nor anything in /System/Library
. Those directory spaces are managed by Apple as part of OS X. You risk breaking your system if you change or delete the wrong thing there. The best way to manage different versions is to modify your shell PATH
environment variable; then you can use /usr/bin/env
if needed. You can also use shell aliases or just use absolute paths. The Python installers from python.org have an option to automatically modify your shell initialization files appropriately.
精彩评论