#/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)
Centos 7 安装python 版本
原创breaklinux 博主文章分类:Python ©著作权
文章标签 安装python 版本 文章分类 运维
-
Centos7安装python3.12
centos7 安装高版本的python3.12的方法和过程;
python 软链接 python3 -
虚拟机安装CentOS7
本章节我们将学习如何安装创建一个Linux学习环境。
CentOS VMware 云计算 系统 运维