I have a problem when trying to run a python script on two different computers. On each computer I would like to run the script using python version 2.7.3 however the problem I am having is that the two computers name python 2.7.3 in different ways. One of the computers runs arch linux and on this computer it is named python2. The other computer is running redhat linux and it uses the name python2.7.3.
What should I use in the shebang line so that the script is executable on both computers without requiring any changes? What I really want is some sort of conditional shebang line that could choose which version of Python to use. Am I just out of luck and I have to keep two different versions of the script?
P.S. I can't just use #!/usr/bin/env python as on the arch linux computer this would refer to python 3.2.3 and on the redhat linux computer it would refer to python 2.4.
python2
, so really this is sort of a packaging issue on redhat's behalf (amogst other distros). - WhyNotHugopython2.7.3 my-program.py
:) - Shaung#!/usr/bin/env python
or#!/usr/bin/env python2
and guard version dependent code with explicit checks for the appropriate Python version (usingsys.version_info
). Failing that then simlinks or @Shaung's solution is the easiest. - Chris