-
step1:安裝依賴環境
# 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
-
step2:下載python3.6
wget https://www.python.org/ftp/python/3.6.4/Python-3.6.4.tgz
-
step3:安裝Python3
解壓python3.tgz
tar -xvf Python-3.6.4.tgz
創建python3的文件路徑
mkdir /usr/local/python3
-
step4:編譯(在解壓的文件夾下)
./configure --prefix=/usr/local/python3
-
step5:安裝(在解壓的文件夾下 )
make make install<br>先make再make install
-
step6:創建新版本軟連接
①修改舊版本
mv /usr/bin/python /usr/bin/python_bak
②創建新的軟連接
ln -s /usr/local/python3/bin/python3 /usr/bin/python
③檢查python的版本
python -V
-
step7:配置pip3
將/usr/local/python3/bin加入PATH
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
- step8:更新pip3 版本
查看當前pip3版本信息
pip3-V
更新pip3 版本
pip3 install --upgrade pip
查看pip3安裝的庫
pip3 freeze
完成