Centos7配置Python3.10.1
Centos7配置Python3.10.1环境
部署依赖环境
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
去Python官网下一个Linux系统下的安装包
3.10.1版本链接:https://www.python.org/ftp/python/3.10.1/Python-3.10.1.tgz
下载好之后xftp建个目录传进去
mkdir /usr/local/python3
tar -zxvf Python-3.10.1.tgz
yum install gcc
yum install libffi-devel -y
cd Python-3.10.1
./configure --prefix=/usr/local/python3
make
make install
最后两步时间可能会有点久,请耐心等待,看到error也不要慌张。
建立Python3和pip3的软链
ln -s /usr/local/python3/bin/python3 /usr/bin/python3
ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3
将/usr/local/python3/bin加入PATH
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
检查Python3及pip3是否正常可用
python3 -V
pip3 -V
进入Python命令行
python3