Detailed tutorial on installing Python 3.6.6 from scratch on CentOS 7.5

Detailed tutorial on installing Python 3.6.6 from scratch on CentOS 7.5

ps: The environment is as the title

Install possible dependencies

yum install openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel sqlite-devel gcc gcc-c++ openssl-devel

Download the compressed file

Get the download link

Here we select Python 3.6.6 from the Python official website. The download address is as follows

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

You can also choose your own version. The official FTP is

https://www.python.org/ftp/python/

Download the compressed file

Now we enter CentOS (the directory is irrelevant at this time), the command is as follows

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

Download completed, go to next step

Unzip the compressed file

Mobile compressed file

I personally install Python in the /usr directory. First, we move the Python compressed package to the specified folder. We need to use the mv command to move it.

mv Current position Moved position

mv /root/Python-3.6.6.tar.xz /usr/

Enter the directory

We use the cd command to enter the target folder and use ls to view all files in the folder.

cd /
ls
cd usr/
ls

We can see that the move has been successful.

Unzip

Decompress tar.xz and use the xz -d command to decompress the tarball.

xz -d Python-3.6.6.tar.xz

We use ls again to view

We then decompress the tar package using the tar command

tar -xvf Python-3.6.6.tar

The screen scrolls quickly and the decompression is completed

We can see that there is already a Python-3.6.6 directory

Compile and install Python

Let's go into the python directory first

cd Python-3.6.6/

Add Configuration

In fact, it is to compile and install Python to the specified directory, here specified as /usr/python

./configure --prefix=/usr/python

ps: If an error occurs (as shown below), you need to install gcc first

yum install -y gcc

Correct result

Compile and install

Using make command

make

Next you need to wait

After completion, use the make install command

make install

wait

If a zlib error occurs (as shown below), you need to install zlib first and then re-install it.

yum -y install zlib*

If a ctypes error occurs, you need to install libffy first

yum install libffi-devel -y

Python installation completed screenshot

At this point, we return to the previous directory. If you see a python folder, it means success. If you lack dependencies during compilation and installation, there may be no folder. In this case, you need to start over from adding configuration.

Creating a Soft Link

Creating a soft link is equivalent to configuring environment variables

ln -s /usr/python/bin/python3 /usr/bin/python3

At this point we can enter python by typing python3 in any directory

Let's test import _ssl

Perfect!

We also need to configure pip's soft link to use pip

ln -s /usr/python/bin/pip3 /usr/bin/pip3

Install pymysql test using pip3

Summarize

The above is the tutorial on how to install Python 3.6.6 from scratch on CentOS 7.5. I hope it will be helpful to you. If you have any questions, please leave me a message and I will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website!

You may also be interested in:
  • How to install Python 3.6 on Alibaba Cloud CentOS 7.4
  • Solution to error when installing python3.6.4 based on centos7
  • How to compile and install Python 3.6.2 in CentOS 7.3
  • Summary of problems encountered when installing Python 3.6 under CentOS 7

<<:  Detailed explanation of MySql slow query analysis and opening slow query log

>>:  Code block highlighting can be copied and displayed js plug-in highlight.js + clipboard.js integration

Recommend

Introduction to building a DNS server under centos7

Table of contents 1. Project environment: 2: DNS ...

Detailed explanation of the lock structure in MySQL

Mysql supports 3 types of lock structures Table-l...

How to dynamically modify the replication filter in mysql

MySQL dynamically modify replication filters Let ...

JavaScript implements select all and unselect all operations

This article shares the specific code for JavaScr...

Complete steps to install Anaconda3 in Ubuntu environment

Table of contents Introduction to Anaconda 1. Dow...

How to upload the jar package to nexus via the web page

When using Maven to manage projects, how to uploa...

Detailed explanation of common methods of JavaScript Array

Table of contents Methods that do not change the ...

Uncommon but useful tags in Xhtml

Xhtml has many tags that are not commonly used but...

Introduction to Semantic XHTML Tags

The first point to make is that people can judge t...

How to purchase and initially build a server

I haven't worked with servers for a while. No...

Nginx defines domain name access method

I'm building Nginx recently, but I can't ...

JavaScript to implement retractable secondary menu

The specific code for implementing the retractabl...