Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The method of installing Python3.6.6 from scratch in CentOS7.5

2025-04-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article will explain in detail the method of installing Python3.6.6 from scratch in CentOS7.5. The editor thinks it is very practical, so I share it with you for reference. I hope you can get something after reading this article.

Ps: environment such as title

Dependencies that may be required to install

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

Download the compressed package

Get download link

Here we choose the Python3.6.6 of the official website of Python. The download address is as follows.

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

The viewer can also choose the version by himself. The official FTP is

Https://www.python.org/ftp/python/

Download the compressed package

Now let's enter CentOS (the directory can be ignored at this time), and the command is as follows

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

The download is complete and proceed to the next step

Decompress the package

Mobile compressed package

I am used to installing Python in the / usr directory. We first move the Python package to the specified folder. We need to use the mv command to move it.

Mv's current position, moving 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 the files under the folder

Cd / lscd usr/ls

We can see that the movement has been successful.

Decompression

Extract tar.xz use the xz-d command to extract the tar package

Xz-d Python-3.6.6.tar.xz

Let's use ls again to see

Let's extract the tar package again and use the tar command

Tar-xvf Python-3.6.6.tar

The screen scrolls quickly and the decompression is complete.

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

Compile and install Python

Let's go to the python directory first

Cd Python-3.6.6/

Add configuration

In fact, the Python is compiled and installed to the specified directory, which is specified as / usr/python here.

. / configure-- prefix=/usr/python

Ps: if an error occurs (as follows), you need to install gcc first.

Yum install-y gcc

Correct result

Compilation and installation

Use the make command

Make

Next you need to wait.

Use the make install command when you are finished

Make install

wait for

If there is a zlib error (as below), you need to install zlib first and then re-perform the installation

Yum-y install zlib*

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

Yum install libffi-devel-y

Screenshot of python installation completed

At this point, we first return to the directory above. If you see the python folder indicates success, if you lack dependencies in the compilation and installation, there may be no folder. At this point, you need to start over from the place where you added the configuration.

Create 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 the import _ ssl

Perfect!

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

Ln-s / usr/python/bin/pip3 / usr/bin/pip3

Install the pymysql test using pip3

This is the end of this article on "how to install Python3.6.6 from scratch in CentOS7.5". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it out for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report