Slug: mac-os-x-ignoring-python-shebang Date: 2004-03-16 Title: Mac OS X ignoring python shebang?! layout: post
I've recently added a second Python install on my OS X box, in /opt/Python. I've got a script with a shebang at the top:
#!/opt/Python/bin/python
When I run the script like so:
/opt/Python/bin/python alltests.py
It runs fine. If I just:
./alltests.py
I get an error:
Fatal Python error: Interpreter not initialized (version mismatch?)
Abort trap
and I can confirm that it's running the script in the System python - the first two lines in the script are:
import sys
print sys.path
Which prints:
['/opt/myProj', '/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python23.zip', '/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3', '/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/plat-darwin', '/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/plat-mac', '/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/plat-mac/lib-scriptpackages', '/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/lib-tk', '/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/lib-dynload', '/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site-packages']
So why is Mac OS X not using the python spec'd in the shebang?
(I also checked the line endings - unix.)
Edit on Github