centos according to python3

Yesterday Ali cloud activity, bought a 2-core 4G server, and then recently learned Python, ready to get a set of Python environment on top.

Originally thought it was simple to install what gets the job done, the results are really stepped on countless countless pit! Finally to somehow.

In fact, it is easy to install python3.7 itself, there is nothing difficult, mainly when installing pip encountered a lot of problems. Here say what I stepped on the concrete pit, as well as a solution. Specific installation steps online very, very much.

Reference: https: //blog.csdn.net/u013214212/article/details/81540840

Step inside this shining completely done, there is no problem on that. But in order to prevent accidents, or their own summary again.

First, install dependencies, this specific role I do not know, I feel like at the time of installation will use the tool.

yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make
two, then perform the installation tool, the installation does not lead to pip the installation to fail, and this is the biggest I encountered a pit!

yum install libffi-devel -y
three python3.7 download package, there are two methods, one is downloaded from the official website, and upload it to the CentOS, CentOS another by a direct download wget command. Both can be.

1, the official download:

        Open the python's official website: https: //www.python.org/ -> Downloads -> Source code -> Latest Python 3 Release - Python 3.7.0 -> pulled the bottom, select Gzipped source tarball, download to a local, you can then upload to the server

2, wget command:

wget https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tgz
Third, the installation Python3.7.0, the following code can be executed sequentially

-zxvf Python-3.7.0.tgz tar
cd Python-3.7.0
./configure
the make the make install &&
if there is a "ModuleNotFound: No module named '_ctypes '" error that you missed the second step! ! !

Fourth, configure the environment variables (python and the pip)

Music Videos / usr / bin / Python /usr/bin/python.bak
LN -s / usr / local / bin / to python3 / usr / bin / Python
Music Videos / usr / bin / PIP /usr/bin/pip.bak
LN -s / usr / local / bin / pip3 / usr / bin / pip
five, this time to test

1, verify python, if the version number displayed is 3.7.0, on behalf of the installation was successful (CentOS will own a python2.7)

2, verify pip, pip look at the version number is not 10.0.1, and finally in brackets is not 3.7

If these two are no problem, to prove that you have successfully installed! If you have questions, you try it again!

Fifth, configure yum

but! ! At this time, you enter what yum, you will find that your yum not working! Why, just make it better?

Mainly because yum is dependent on python2.7, you changed the python 3.7, and naturally so bad. But do not worry, python2.7 still in your computer. Just change in the relevant yum can rely on.

vim / usr / libexec / urlgrabber- ext-down
after the open, find a / usr / bin / python, and followed by the 2.7 on it! That is /usr/bin/python2.7

Then enter

vi / usr / bin / yum
practices and the same as above, but also changed python2.7 on it!

Then, your python development environment to configure a success! ! The most deceptive or second step ah! ! TAT
--------------------- 
Author: _ a century 
Source: CSDN 
Original: https: //blog.csdn.net/qq_36288025/article/details/82534508 
copyright Disclaimer: This article is a blogger original article, reproduced, please attach Bowen link!

Guess you like

Origin blog.csdn.net/Edu_enth/article/details/93494145