Linux中安装python3
时间: 2023-11-30 09:41:06 浏览: 87
Linux服务器上安装Python3的两种方式
在Linux中安装Python3的步骤如下:
1. 准备工作
1.1. 安装Python3的依赖
```shell
sudo apt-get update
sudo apt-get install -y build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev wget
```
1.2. 下载Python3安装包
```shell
wget https://www.python.org/ftp/python/3.7.2/Python-3.7.2.tgz
```
2. 安装Python3
2.1. 配置安装路径
```shell
tar -zxvf Python-3.7.2.tgz
cd Python-3.7.2
./configure prefix=/usr/local/python3
```
2.2. 编译安装Python3
```shell
make && make install
```
2.3. 添加软链接
```shell
ln -s /usr/local/python3/bin/python3 /usr/bin/python3
```
3. 检测是否安装成功
```shell
python3 -V
```
4. 升级pip
```shell
pip3 install --upgrade pip
```
阅读全文