How to install on Ubuntu 18.04 Python3.7

 

Python is one of the world's most popular programming language, with its easy to learn syntax, Python is an excellent choice for beginners and experienced developers. With hot in recent years, artificial intelligence and big data, Python is a further surge in popularity, there is a trend rather than taking the first list of programming languages.

Python is a very general-purpose programming language, you can use it to accomplish anything you want, write small scripts, build games, website development, creation machine learning algorithms to analyze data and so on.

Python 3.7 is the latest major version of the Python language, which includes many new features, such as delayed type of evaluation comments, support for data class and context variables, access to the property's custom modules and so on.

This tutorial describes two methods Python 3.7 installed on Ubuntu 18.04: deadsnakes PPA using the standard tools apt, and build from the source code.

The same steps apply to Ubuntu 16.04 and Ubuntu derivative version of any series of Kubuntu, Linux Mint and Elementary OS such as Ubuntu-based distributions, including.
Ready condition

You need to install software packages on the Ubuntu system as a user logged on with sudo access.
Use Apt installed Python 3.7 in Ubuntu 18.04

Using apt to install Python 3.7 is a relatively simple procedure on Ubuntu, just a few minutes:

01, first update the package list and install the prerequisites:

sudo apt update
sudo apt install software-properties-common

02, Next, add deadsnakes PPA to your sources list:

sudo add-apt-repository ppa:deadsnakes/ppa

Press Enter when prompted to continue:

Press [ENTER] to continue or Ctrl-c to cancel adding it.

03, after the repository is enabled, use the following command to install Python 3.7:

sudo apt install python3.7

04, at this time, Python 3.7 is already installed on your Ubuntu system, ready to be used. You can enter the following command to verify:

python3.7 --version

Export

Python 3.7.2

Python 3.7 from source mounted on Ubuntu

In this section, we will show you how to download and compile Python 3.7:

01, first update the list of packages required to build and install the Python source package:

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

02, use the following wget command to download the latest version of the source code from the download page Python:

wget https://www.python.org/ftp/python/3.7.2/Python-3.7.2.tar.xz

03, after the download is complete, extract the compressed package

takes -xf Python 3.7.2.tar.xz

04, Next, navigate to the Python source directory and run the configure script, which will perform a number of checks to make sure that all the dependencies exist on the system:

cd Python-3.7.2
./configure --enable-optimizations

-enable-optimizations option to optimize Python binary file by running multiple tests, which will slow down the build process.

05, make use Python to start the build process:

make -j 8

In order to shorten the time to build, modify -j flag according to processor. If you do not know the number of processor cores, you can find it by typing nproc. My system has eight cores, so I use the -j 8 logo.

06, after the building is complete, type the following command to install the Python binaries:

sudo make altinstall

Do not use the standard make install, because it overrides the default system python3 binaries.

07, Python 3.7 is installed and ready to use, enter the following command to verify:

python3.7 --version

Python 3.7.2

Guess you like

Origin www.cnblogs.com/aspsea/p/11138462.html