卸载原有python版本
sudo apt-get remove --purge python3
sudo apt-get remove --auto-remove python3
sudo apt-get purge --auto-remove python3
sudo apt-get autoclea python3
下载python3.6
wget https://www.python.org/ftp/python/3.6.8/Python-3.6.8.tgz
从压缩包解压源代码:
tar xvf Python-3.6.8.tgz
进入目录,执行 ./configure 配置构建文件:
cd Python-3.6.8
./configure --enable-optimizations
编译并安装:
make -j8 && sudo make altinstall
收尾
sudo make clean
修改软连接
sudo ln -s /usr/local/bin/python3.6 /usr/bin/python3
安装pip
wget https://bootstrap.pypa.io/get-pip.py
sudo python3 get-pip.py
或者
apt install python3-pip
更新pip
pip3 install -U pip
修改pip源一
在/etc/目录下边创建pip.conf文件(此处使用vim直接编辑,默认会进行创建)
cd /etc/
sudo vim pip.conf
在打开的pip.conf文件内写入以下内容
[global]
trusted-host=mirrors.aliyun.com
index-url=https://mirrors.aliyun.com/pypi/simple/
保存即可
修改pip源一
pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple pip -U
pip3 config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple