Ubuntu 22.04安装python3.11
时间: 2023-09-18 19:09:45 浏览: 163
ubuntu安装python3.9 ubuntu安装python3.9
5星 · 资源好评率100%
1. 首先,打开终端,输入以下命令更新系统:
```
sudo apt update
sudo apt upgrade
```
2. 安装依赖包:
```
sudo apt install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev wget
```
3. 下载Python 3.11源代码:
```
wget https://www.python.org/ftp/python/3.11.0/Python-3.11.0.tgz
```
4. 解压源代码:
```
tar -xf Python-3.11.0.tgz
```
5. 进入解压后的目录:
```
cd Python-3.11.0
```
6. 配置编译选项:
```
./configure --enable-optimizations
```
7. 编译和安装:
```
make -j 4
sudo make altinstall
```
8. 验证Python版本:
```
python3.11 --version
```
如果输出Python 3.11.0,则安装成功。
9. 可以将Python 3.11设置为系统默认Python版本,方法如下:
```
sudo update-alternatives --install /usr/bin/python python /usr/local/bin/python3.11 1
sudo update-alternatives --config python
```
运行第二个命令后,会列出所有可用的Python版本,选择Python 3.11并按Enter键即可。
阅读全文