1.下載下傳
1.官網下載下傳
https://www.python.org/ftp/python/3.6.8/Python-3.6.8.tgz
2.解壓文檔
tar -zxvf Python-3.6.8.gz
2.準備
1.編譯環境
yum install gcc
2.安裝依賴包
python的pip需要依賴
zlib
,
openssl
。
yum install zlib* openssl*
3.安裝
1.進入目錄 Python-3.6.8
Python-3.6.8
cd Python-3.6.8
2.預編譯
./configure --prefix=/usr/python-3.6.8 --enable-optimizations
3.編譯
4.安裝
4.配置環境變量
1.打開檔案 .bashrc
.bashrc
sudo vim ~/.bashrc
2.編輯檔案 .bashrc
.bashrc
在檔案的最後一行建立一行
PATH=$PATH:/usr/python-3.6.8/bin
# .bashrc
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
# Uncomment the following line if you don't like systemctl's auto-paging feature:
# export SYSTEMD_PAGER=
# User specific aliases and functions
PATH=$PATH:/usr/python-3.6.8/bin
3.儲存退出 .bashrc
.bashrc
Esc
->
:wq
4.應用配置 .bashrc
.bashrc
source ~/.bashrc