Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Try to inplace upgrade from python 2.5 to 2.7
#!/usr/bin/env python2
'''
# ./inplace-upgrade.py
python version: (2, 5, 2, 'final', 0)
[***] newer python interpreter available. switching versions...
python version: sys.version_info(major=2, minor=7, micro=9, releaselevel='final', serial=0)
'''
import os, sys
def try_switch_to_python2_7():
py27 = "/usr/bin/python2.7"
if sys.version_info < (2,7) and os.path.exists(py27):
print "[***] newer python interpreter available. switching versions... "
os.execve(py27,[py27]+sys.argv,os.environ)
sys.exit()
print "python version: ", sys.version_info
try_switch_to_python2_7()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment