在 Ubuntu 18.04 /centos7上安装 Python 3.7

扩展源安装

sudo apt update
sudo apt install software-properties-common
sudo add-apt-repository ppa:deadsnakes/ppa

# 按回车继续
sudo apt install python3.7
python3.7 --version
#安装pip
wget https://bootstrap.pypa.io/get-pip.py
python3.7 get-pip.py
#安装python3.7-develop 包
sudo apt install python3.7-dev

源码安装

sudo apt updatesudo apt install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev wget
wget https://www.python.org/ftp/python/3.7.3/Python-3.7.3.tar.xz
tar -xf Python-3.7.3.tar.xz
cd Python-3.7.3
#配置
./configure --enable-optimizations
#编译 使用8个cpu同时编译
make -j 8
#安装python3.7
sudo make altinstall
#测试
python3.7 --version
#安装pip
wget https://bootstrap.pypa.io/get-pip.py
python3.7 get-pip.py
#安装python3.7-develop 包
sudo apt install python3.7-dev

centos7

#源码安装
1. 先安装依赖
yum groupinstall "Development Tools" -y
yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel libpcap-devel xz-devel libffi-deve -y
2.下载源码包
https://www.python.org/ftp/python/3.7.4/Python-3.7.4.tar.xz
tar -xvf Python-3.7.4.tar.xz
cd Python-3.7.4
#配置
./configure --prefix=/usr/local/python3
#可选开启 优化
./configure --enable-optimizations
#编译 (-j 8 代表开启8核同时编译)
make -j 8 
#安装
make install

转载于:https://www.cnblogs.com/lovesKey/p/11355630.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值