Deepin编译python
Deepin编译python
系统: Deepin20.9 64位
Python版本: 3.8.3
准备编译环境
# 更新源
sudo apt update
# 安装编译工具
sudo apt-get install gcc g++ make
# 安装依赖
sudo apt install -y wget build-essential zlib1g-dev libreadline-dev libncursesw5-dev libssl-dev libgdbm-dev libnss3-dev libffi-dev libncurses5-dev libsqlite3-dev tk-dev libc6-dev libbz2-dev
解压
# 下载
wget --no-check-certificate https://www.python.org/ftp/python/3.8.9/Python-3.8.9.tgz
# 解压
tar -zxvf Python-3.8.9.tgz
# 目录
cd Python-3.8.9/
编译安装
# 编译
./configure --prefix=/usr/local/python3.8.9 --enable-optimizations
# 安装
make
sudo make install
配置Python版本
# 系统自带的Python
# 参数说明
# --install表示添加
# /usr/bin/python表示软链接路径
# python表示名称
# /usr/bin/python3.7表示实际Python的路径
# 2表示权重
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.7 2
# 自己的Python
sudo update-alternatives --install /usr/bin/python python /opt/shortcut/python3/bin/python3.8 3
配置pip版本
sudo update-alternatives --install /usr/bin/pip pip /usr/local/bin/pip3.7 2
sudo update-alternatives --install /usr/bin/python python /opt/shortcut/python3/bin/python3.8 3
pip使用国内源(Linux)
pip config set global.index-url https://mirrors.aliyun.com/pypi/simple
pip config set install.trusted-host mirrors.aliyun.com