这里以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