Install Python3.8 on Ubuntu

There are two ways to install Python on ubuntu: online installation and source code compilation and installation.

Method 1: Use apt to install online

1. Update the package list and install the prerequisite components:

$ sudo apt update
$ sudo apt install software-properties-common
  1. Add the Deadsnakes PPA to your system's sources list:
$ sudo add-apt-repository ppa:deadsnakes/ppa
  1. Once the repository is enabled, install Python 3.8 with the following command:
$ sudo apt install python3.8
  1. Verify that the installation was successful by typing:
$ python3.8 --version

Method 2: Source code compilation and installation

1. Update the package list and install the packages needed to build Python:

$ sudo apt update
$ sudo apt install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev wget

2. Download the source code

$ wget https://www.python.org/ftp/python/3.8.0/Python-3.8.0.tgz
  1. Once the download is complete, unzip the downloaded file:
$ tar -xf Python-3.8.0.tgz
  1. Change to the Python source directory and execute the configure script, which performs a number of checks to ensure all dependencies are present on the system:
$ cd Python-3.8.0
$ ./configure --enable-optimizations

The --enable-optimizations option optimizes the Python binary by running multiple tests, which can slow down the build process.

  1. Start the Python 3.8 build process:
$ make
  1. After the build process is complete, enter the following command to install the Python binaries:
$ sudo make altinstall

Do not use the standard make install as it will overwrite the default system python3 binary.
7. Python 3.8 is installed and ready to use, verify by running the following command:

$ python3.8 --version

Guess you like

Origin blog.csdn.net/somken/article/details/128775179