Python3安装配置 for centos

2022-02-13  本文已影响0人  卡门001

一、准备

yum -y install zlib-devel bzip2-devel openssl-devel 
yum -y install ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel xz-devel
yum -y install wget
yum install -y gcc #编译器
yum install libffi-devel -y

二、openssl安装

cd /opt
find /etc/ -name openssl.cnf -printf "%h\n"
--
/etc/pki/tls

# 3.x的版本在centos 8下安装不兼容
curl -O https://www.openssl.org/source/openssl-1.1.1m.tar.gz
tar zxvf penssl-1.1.1m.tar.gz
cd openssl-1.1.1m
./config --prefix=/usr/local/custom-openssl --libdir=lib --openssldir=/etc/pki/tls
make -j1 depend
make -j8 && make install_sw 
popd

四、下载安装python3

mkdir -p /usr/local/python3 
cd /opt
wget https://www.python.org/ftp/python/3.10.2/Python-3.10.2.tar.xz
tar xvf Python-3.10.2.tar.xz
cd Python-3.10.2
./configure -C --with-openssl=/usr/local/custom-openssl \
--with-openssl-rpath=auto --prefix=/usr/local/python3

make -j8
make altinstall

安装成功,提示如下


image.png

五、安装后配置与校验

ln -s /usr/local/python3/bin/python3 /usr/bin/python3
ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3
vim /etc/profile
---
export PATH=$PATH:/usr/local/python3/bin
--

# 生效
source /etc/profile

六、检查版本

python3 -V
pip3 -V
上一篇 下一篇

猜你喜欢

热点阅读