Writing /share/Web/wiki/data/cache/d/d0a228db846fe6754fe0b61d2811e11e.metadata failed
linux:ubuntu:python3升级
差别
这里会显示出您选择的修订版和当前版本之间的差别。
| 后一修订版 | 前一修订版 | ||
| linux:ubuntu:python3升级 [2020/09/21 23:59] – 创建 zhangguo | linux:ubuntu:python3升级 [2023/03/17 10:12] (当前版本) – 外部编辑 127.0.0.1 | ||
|---|---|---|---|
| 行 2: | 行 2: | ||
| https:// | https:// | ||
| + | |||
| + | 在 Ubuntu 16.04 中,python3 的默认版本为 Python 3.5.2 | ||
| + | |||
| + | 像类似'' | ||
| + | |||
| + | |||
| + | 不太建议对系统的python版本进行升级,而是最好采用直接安装anaconda3的方式,这样没有依赖问题,免于折腾。 | ||
| + | ===== - 通过 Apt 安装 ===== | ||
| + | Ubuntu 官方 apt 库中还未收录 python 3.8,这里使用 deadsnakes PPA 库安装。 | ||
| + | |||
| + | ==== - 安装依赖包 ==== | ||
| + | < | ||
| + | $ sudo apt update | ||
| + | $ sudo apt install software-properties-common | ||
| + | </ | ||
| + | |||
| + | |||
| + | |||
| + | ==== - 添加源 ==== | ||
| + | |||
| + | < | ||
| + | $ sudo add-apt-repository ppa: | ||
| + | |||
| + | Press [ENTER] to continue or Ctrl-c to cancel adding it. | ||
| + | </ | ||
| + | |||
| + | |||
| + | ==== - 安装python 3.6及以上 ==== | ||
| + | < | ||
| + | $ sudo apt install python3.8 | ||
| + | |||
| + | $ python3.8 -V | ||
| + | Python 3.8.2 | ||
| + | </ | ||
| + | |||
| + | ===== - 配置 python3.8 为系统默认 python3 ===== | ||
| + | |||
| + | ==== - 将 python 各版本添加到 update-alternatives ==== | ||
| + | < | ||
| + | $ which python3.8 | ||
| + | / | ||
| + | |||
| + | $ sudo update-alternatives --install / | ||
| + | |||
| + | $ which python3.5 | ||
| + | / | ||
| + | |||
| + | $ sudo update-alternatives --install / | ||
| + | </ | ||
| + | |||
| + | ==== - 配置 python3 默认指向 python3.8 ==== | ||
| + | |||
| + | < | ||
| + | $ sudo update-alternatives --config python3 | ||
| + | |||
| + | There are 2 choices for the alternative python3 (providing / | ||
| + | |||
| + | | ||
| + | ------------------------------------------------------------ | ||
| + | * 0 / | ||
| + | | ||
| + | | ||
| + | |||
| + | Press < | ||
| + | </ | ||
| + | |||
| + | |||
| + | ==== - 测试 python 版本 ==== | ||
| + | |||
| + | < | ||
| + | $ python3 -V | ||
| + | |||
| + | Python 3.8.2 | ||
| + | </ | ||
| + | |||
| + | |||
linux/ubuntu/python3升级.1600703954.txt.gz · 最后更改: 2023/03/17 10:12 (外部编辑)