#coding = Utf-8import Osimport sysif (os.getuid () = = 0):p asselse:print ("is not root user") Sys.exit (1) #version = input ("Please input Python version (2.7/3.6)") Version = 2.7if Version = = 2.7:packagename = "Python-2.7.13" else:packagename = "Py thon-3.6.2 "Os.system (" RM-RF "+ packagename+" * ") if (Version = = 2.7): url =" https://www.python.org/ftp/python/2.7.13/ Python-2.7.13.tgz "elif Version = = 3.6:url =" https://www.python.org/ftp/python/3.6.2/Python-3.6.2.tgz "Else:print (" Input error ") Sys.exit (1) cmd =" wget "+ urlres = Os.system (cmd) if res! = 0:print (" Download failed Check network ") cmd =" ta R XVF "+ PackageName +". tgz "res = os.system (cmd) if res! = 0:p rint (" Tar Failed ") Os.system (" rm "+ PackageName +". tgz ") sy S.exit (1) cmd = "CD Python-2.7.13 &&./configure--prefix=/usr/local/python2.7 && make && make INS Tall "res = Os.system (cmd) if res! = 0:os.system (" RM-RF "+ PackageName) Os.system (" rm "+ PackageName +". tgz ") Print (" Make Failed ") Sys.exit (1)
Python Auto-Install python2.7