debian系统升级python

发布于 2021-03-23  25 次阅读


更新相关依赖lib和软件

#更新源 
apt update
#安装相关软件包 
apt-get  -y   build-essential libssl-dev zlib1g-dev  libbz2-dev libreadline-dev libsqlite3-dev  curl llvm libncurses5-dev libncursesw5-dev xz-utils tk-dev libffi-dev liblzma-dev

下载Python源码包(linux版本)

#下载Python包
wget https://www.python.org/ftp/python/3.9.2/Python-3.9.2.tar.xz
#解压缩Python3压缩包
tar -xvf Python-3.9.2.tar.xz

#进入对应的目录
cd Python-3.9.2/

编译Python3.9.2

#配置和检查环境,生产Makefile,指的安装到/usr/local/python3
./configure --enable-optimizations --prefix=/usr/local/python3
#编译
make
#安装
make install

修改软连接

#删除软连接 
-rf /usr/bin/python3
#重新生成软链接 
-s /usr/local/python3/bin/python3 /usr/bin/python3
#重新测试python3版本,输入
python3 -V

升级pip

python3 -m pip install -U pip