In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces the relevant knowledge of CentOS how to install Python, the content is detailed and easy to understand, the operation is simple and fast, and has a certain reference value, I believe you will have something to gain after reading this CentOS how to install Python article, let's take a look at it.
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 the article on "how to install Python in CentOS". Thank you for reading! I believe you all have a certain understanding of "how to install Python in CentOS". If you want to learn more, you are welcome to follow the industry information channel.
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.