分类: Python
Debian11安装Python 3.11最新版

Debian11默认的Python版本是python3.9.2,以下是升级为Python3.11版的步骤:
1、更新程序包并安装依赖环境:

sudo apt update && sudo apt upgrade
sudo apt install wget build-essential libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev libffi-dev zlib1g-dev -y

2、下载Python3.11源码包、解压编译安装:

wget https://www.python.org/ftp/python/3.11.0/Python-3.11.0.tar.xz
tar xvf Python-3.11.0.tar.xz
cd Python-3.11.0
./configure --prefix=/usr/local/python3.11 --enable-optimizations
#--enable-optimizations为优化性能选项,--prefix=PATH 指定安装目录,可根据需要进行选择。
#默认安装路径为 /usr/local/bin
make -j 4
make install

3、修改默认打开为python3.11版本

rm /usr/bin/python3 -rf #删除默认3.9.2的链接
ln -s /usr/local/python3.11/bin/python3.11 /usr/bin/python3
ln -s /usr/local/python3.11/bin/python3.11 /usr/bin/python
ln -s /usr/local/python3.11/bin/pip3.11 /usr/bin/pip3
ln -s /usr/local/python3.11/bin/pip3.11 /usr/bin/pip

现在默认使用就是Python3.11版本了:

root@debian115:~# python -V
Python 3.11.0

root@debian115:~# python
Python 3.11.0 (main, Nov 25 2022, 08:15:37) [GCC 10.2.1 20210110] on linux
Type "help", "copyright", "credits" or "license" for more information.


相关博文:

发表新评论