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