【Python】升级Python版本

Posted by 西维蜀黍 on 2020-08-06, Last Modified on 2021-09-21

macOS

$ brew install python3
$ brew link python@3.8

Ubuntu

Install ppa

This PPA contains more recent Python versions packaged for Ubuntu. Install ppa by running the following command.

$ sudo add-apt-repository ppa:deadsnakes/ppa

Update packeges

Now, update your packages by running the following command.

$ sudo apt-get update

安装Python3.8

$ sudo apt-get install python3.8

Add python3.6 & python3.7 to update-alternatives

$ sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.7 1
$ sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.8 2

Update python3 to point to python3.8

$ sudo update-alternatives --config python3

Enter 2 for python3.8

Test the version of python

$ python3 -V
Python 3.8.0

Reference