发布时间:2019-08-23 08:00:56编辑:auto阅读(1574)
#/root/.pyenv/shims/python #python 3.0 # -*- coding:UTF-8 -*- import os import sys class Package(): def install(self): cmd = 'yum -y install gcc* make cmake' if res != 0: print("依赖包安装失败程序即将停止") sys.exit(1) 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' A = Package() A.install() elif version == '3.5': url = 'https://www.python.org/ftp/python/3.5.2/Python-3.5.2rc1.tgz' A = Package() A.install() elif version == '3.7': url = 'https://www.python.org/ftp/python/3.7.0/Python-3.7.0a4.tgz' A = Package() A.install() 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)
上一篇: 000-Python常量与变量
下一篇: Python编写地区选择-Dict
48118
46817
37737
35052
29591
26248
25180
20219
19858
18327
5999°
6681°
6176°
6162°
7273°
6113°
6220°
6698°
6666°
8058°