python脚本使用源码安装不同版本的python
# coding=utf-8 import os
import sys # 判断是否是root用户
if os.getuid() == 0:
pass
else:
print('当前用户不是root用户,请以root用户执行脚本')
sys.exit(1) version = raw_input('请输入您想安装的python版本(2.7/3.5)')
if version == '2.7':
url = "https://www.python.org/ftp/python/2.7.15/Python-2.7.15.tar.xz"
elif version == '3.5':
url = "https://www.python.org/ftp/python/3.5.7/Python-3.5.7.tar.xz"
else:
print "您输入的版本号有误,请输入2.7或者3.5"
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.15'
else:
package_name = 'Python-3.5.7'
cmd = 'tar xf ' + package_name + '.tar.xz' res = os.system(cmd)
if res != 0:
os.system('rm -f ' + package_name + '.tar.xz')
print '解压源码包失败,请重新运行这个脚本下载源码包'
sys.exit(1) cmd = 'cd ' + package_name + '&& ./configure -- prefix=/usr/local/python'+ version + ' && make && make install'
res = os.system(cmd)
if res != 0:
print '编译python源码包失败,请检查是否缺少依赖库'
sys.exit(1)
python脚本使用源码安装不同版本的python的更多相关文章
- centos7 源码安装指定版本的php7
很多时候可能会遇到需要手动源码安装软件的时候,所以自己实践了一把,并且把安装过程中遇到的问题,以及在网上找到的解决办法(实测有效)都记录下来,方便日后学习实践. 1. 系统环境 # cat /etc/ ...
- Ubuntu16.04 / OpenCV / Python 源码安装
为什么需要源码安装? 1. 对 Python 版的 OpenCV,Ubuntu 有两种安装方式: 源码安装:官网(https://opencv.org/releases.html)下载源代码,在机器上 ...
- 部署 LNMP(源码安装版本)shell脚本
#!/bin/bash # 一键部署 LNMP(源码安装版本) menu() { clear echo " ##############‐‐‐‐Menu‐‐‐‐##############& ...
- 源码安装python +NGINX 的坎坷路 +uwsgi安装 部署django 的CRM项目
一.Nginx安装(基于ubuntu17.10 版本) 首先我们是基于源码安装,主要有如下步骤 1.安装依赖包 1.安装gcc g++的依赖库 sudo apt-get install build-e ...
- Centos6.6上源码安装Nodejs V4版本
本来就是想在vps上装一个Ghost博客,这个博客依赖的是Nodejs,然后推荐的是V4版本.然后我就对着官网的步骤安装,发现根本没有Centos6 i386的资源了(64位的还是有的), 我只能在那 ...
- maridb\mysql 源码安装,以10.1.26版本为例
mysql 源码安装(mariadb 10.1.26) 1.环境部署 1 安装cmake 源码安装三部曲或者yum install cmake2安装依赖包yum install -y ncurses- ...
- RHEL6从源码安装python及其他软件包
RHEL6从源码安装python及其他软件包 ## install ssl $ sudo yum install openssl-devel or: $ sudo apt-get install li ...
- CentOS7源码安装qbittorrent最新版本
CentOS的软件 yum 里 yum search qbittorrent yum info qbittorrent 找到的是3.37版本 官网最新的是4.12版本.但需要源码安装: 官网下载最新版 ...
- Python并发编程-redis-3.0.5 源码安装
1.简介 Remote Dictionary Server(Redis)是一个基于 key-value 键值对的持久化数据库存储系统.redis 和 Memcached 缓存服务很像,但它支持存储的 ...
随机推荐
- 微信小程序---存储本地缓存数据
微信小程序之数据缓存 开发中常用setStorageSync来实现本地数据缓存操作 (1)点击缓存案例: <button bindtap="toStorage">存储& ...
- 适用于在线服务的A/B测试方法论
适用于在线服务的A/B测试方法论 简介: 这篇文章旨在介绍适用于为在线服务进行A/B测试(A/B Test)的方法论.中文网络中目前还缺乏全面的入门级介绍. 我将首先讨论在线服务业进行A/B测试所考虑 ...
- rxjs 入门--环境配置
原文: https://codingthesmartway.com/getting-started-with-rxjs-part-1-setting-up-the-development-enviro ...
- 32位JVM和64位JVM的最大堆内存分别是多数?32位和64位的JVM,int类型变量的长度是多数?
理论上说上 32 位的 JVM 堆内存可以到达 2^32,即 4GB,但实际上会比这个小很多.不同操作系统之间不同,如 Windows 系统大约 1.5 GB,Solaris 大约 3GB.64 位 ...
- Django之路——6 Django的模型层(一)
ORM简介 MVC或者MVC框架中包括一个重要的部分,就是ORM,它实现了数据模型与数据库的解耦,即数据模型的设计不需要依赖于特定的数据库,通过简单的配置就可以轻松更换数据库,这极大的减轻了开发人员的 ...
- Python正则提取数据单引号内数据,并判断是否是空列表(是否提取到数据)
#coding=utf- import re string1="asdfgh'355'dfsfas" string2="fafafasfasdfasdf" pa ...
- hive函数之数学函数
hive函数之数学函数 round(double d)--返回double型d的近似值(四舍五入),返回bigint型: round(double d,int n)--返回保留double型d的n ...
- Continuous Subarray Sum II
Description Given an circular integer array (the next element of the last element is the first eleme ...
- 在Ubuntu 或 Debian 系统环境安装MYSQL数据库
一.第一步下载myslq安装程序 sudo apt-get install mysql-server mysql-client apt-get程序会自动下载安装最新的mysql版本.在安装的最后,它会 ...
- Bzoj 2440: [中山市选2011]完全平方数(莫比乌斯函数+容斥原理+二分答案)
2440: [中山市选2011]完全平方数 Time Limit: 10 Sec Memory Limit: 128 MB Description 小 X 自幼就很喜欢数.但奇怪的是,他十分讨厌完全平 ...