标签:bsp version /usr 下载 imp 版本 local yum 执行
#!/root/.pyenv/shims/python #python 3.0 # -*- coding:UTF-8 -*- import os import sys if os.getuid() == 0: print("当前登录客户端ip地址如下") os.system("who|awk '{print $5}'|cut -c 2-14") else: print("当前用户不是root用户,请使用root用户执行此脚本") sys.exit(1) version = input("请输入你想安装的python 版本(2.7|3.5|3.7)") if version == '2.7': url = 'https://www.python.org/ftp/python/2.7/Python-2.7.tgz' cmd = 'yum -y install gcc* make cmake' res = os.system(cmd) if res != 0: print("依赖包安装失败程序即将停止") sys.exit(1) elif version == '3.5': url = 'https://www.python.org/ftp/python/3.5.2/Python-3.5.2rc1.tgz' cmd = 'yum -y install gcc* make cmake' res = os.system(cmd) if res != 0: print("依赖包安装失败程序即将停止") sys.exit(1) elif version == '3.7': url = 'https://www.python.org/ftp/python/3.7.0/Python-3.7.0a4.tgz' cmd = 'yum -y install gcc* make cmake' res = os.system(cmd) if res != 0: print("依赖包安装失败程序即将停止") sys.exit(1) else: print("您输入的版本号有误,请输入2.7和3.5或者3.7") sys.exit(1) cmd = " wget " + url res = os.system(cmd) if res != 0: print("下载源码包失败,请检查网络") sys.exit(1) if version == '2.7': package_name = "Python-2.7" elif version == '3.5': package_name = "Python-3.5.2rc1" else: package_name = "Python-3.7.0a4" cmd = 'chmod a+x ' + package_name +'.tgz' os.system(cmd) cmd = 'tar -xf ' + package_name +'.tgz' res = os.system(cmd) if res != 0: os.system('rm '+ package_name +'.taz') print("解压源码包失败,请重新运行脚本下载") sys.exit(1) cmd = 'cd '+package_name+' && ./configure --prefix=/usr/local/python && make && make install' res = os.system(cmd) if res != 0: print("编译python源码包失败,缺少依赖库") sys.exit(1)标签:bsp version /usr 下载 imp 版本 local yum 执行
原文地址:http://blog.51cto.com/breaklinux/2065438