centos8 python3.7安装
第一步:必备的插件:
(1)先升级:
# yum install -y update
(2)再安装 gcc和make插件:
#yum install gcc gcc-c++
#yum -y install gcc automake autoconf libtool make
#yum groupinstall -y 'Development Tools'
# yum install -y gcc openssl-devel bzip2-devel libffi-devel
第二步 下载和编译python3.7.9
(1)在官方网站下载最新版本python3.7.9
#wget https://www.python.org/ftp/python/3.7.9/Python-3.7.9.tgz
解压缩:
# tar -zxvf Python-3.7.9.tgz
(2)用脚本检验整个编译环境
# ./configure prefix=/usr/local/python3 --enable-optimizations
(3)用make命令编译安装
# make && make install
(4)修改环境变量
# export PATH=$PATH:/usr/local/python3/bin/
第三步 安装PIP
(1)# curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
(2)# python3.7 get-pip.py
(3)测试
# python -V
这样python3.7就正常安装到centos8上了。
以下介绍ubuntu20.04的python3.7安装
注意:转入root权限下
1. 升级
# sudo apt update
# sudo apt upgrade -y
2. 安装编译Python源程序所需的包
# sudo apt install build-essential -y
# sudo apt install libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev -y
# sudo apt-get install zlib1g-dev
3. 下载Python3.7 源程序压缩包
(或者直接在Python官网下载Linux安装包)
# wget https://www.python.org/ftp/python/3.7.9/Python-3.7.9.tgz
4. 解压
# tar -xzvf Python-3.7.9.tgz
5. 配置
# cd Python-3.7.9
# ./configure --enable-optimizations
6. 编译和安装
# sudo make
# sudo make install
7. 查看Python版本
# python3
Python 3.7.9 (default, Nov 21 2018, 16:35:49)
[GCC 7.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
安装成功!
由于用Pip安装软件包速度很慢,因为要访问外网的。这里可以选择国内的源,这里以清华源为例。
8. 升级Pip和更换Pip源
# sudo pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
# pip3 install --upgrade pip