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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2026 CODEPRJ.COM