Linux系统Python3.9.5安装配置

#安装依赖
yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel

#下载Python3 tar包
wget https://www.python.org/ftp/python/3.9.5/Python-3.9.5.tgz

#创建安装位置-可忽略
mkdir -p /usr/local/python3

#解压
tar -zxvf Python-3.9.5.tgz

#安装gcc libffi-devel
yum install gcc
yum install libffi-devel -y

#configure and make
cd Python目录
./configure --prefix=/usr/local/python3

./configure --prefix=/usr/local/python3 --enable-optimizations --with-ssl --enable-shared

make && make install

#创建软连接
ln -s /usr/local/python3/bin/python3 /usr/bin/python3
ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3

#设置环境变量
vim /etc/profile

# vim ~/.bash_profile

# .bash_profile

# Get the aliases and functions

if [ -f ~/.bashrc ]; then

. ~/.bashrc

fi

# User specific environment and startup programs

PATH=$PATH:$HOME/bin:/usr/local/python3/bin

export PATH


#重载环境配置

source ~/.bash_profile

posted @ 2021-05-24 17:38  小清澈  阅读(966)  评论(0编辑  收藏  举报