這裏以python3.7.6爲例
準備:
- 下載Python安裝包:
wget https://www.python.org/ftp/python/3.7.6/Python-3.7.6.tgz
- 解壓Python安裝包
tar xzvf Python-3.7.6.tgz
開始安裝:
-
cd
到剛剛解壓的Python路徑中,然後運行./configure
命令:cd Python-3.7.6 ./configure
-
運行以下命令進行安裝:
make sudo make install
-
查看安裝版本:
python3 -V
安裝最新版pip
:
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
sudo python3 get-pip.py -i https://mirrors.aliyun.com/pypi/simple/
查看安裝版本:
pip -V
# 或者
pip3 -V
修改pypi鏡像源:
清華:
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
阿里雲:
pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/
安裝第三方庫時可能還需要:
sudo apt install python3-dev