Recently read better about python article, suddenly feel python is so powerful, learning python beginning it is from the beginning to build environment. Then start the Linux installation python3 .
In fact, under way to install Linux There are several: Command installation, source code and installation Anaconda installation.
This article focuses on Centos use the source code installation python3 .
Installation requires the use of source code to compile, long time. Command or using the system comes Anaconda installation, simple and efficient.
1. Download the python source files.
Before downloading the source file, directory now build directory for the source files on the server, where we exist / usr / local directory.
First into the local folder, mkdir python3 .
Download the source file, https://www.python.org/ftp/python/ here I download the latest version 3.8
Here you can download the source files are then uploaded to the server, or download directly on the server.
If you downloaded on the server, right-copy link address. (To be uploaded from the machine to please review process server)
Python3 directory into the implementation of wget https://www.python.org/ftp/python/3.8.0/Python-3.8.0.tgz direct download.
At this point, the source file is completely downloaded.
2. Extract compile and install.
unzip files
takes -xzvf Python 3.8.0.tgz
After extracting the generated Python - 3.8.0 directory.
Enter the directory
./configure --prefix=/usr/local/python3
Explain a little above sentence order, overview of the purpose of this statement is to specify what python installation directory, in this case, inside some bin directory, lib directory will then be stored in this directory. If you do not specify the install directory, and finally dispersed python installation files to the default directory of linux, not one. We specify the installation directory, then later unload directly remove directories can be cleanly uninstalled. (His words borrowed from another blog Yuanyuan Main)
After the execution continues in this directory
make
Out a lot of information, do not need him to continue to execute the following command after finished.
make install
As shown below
After the installation is complete, create python3 links.
(Ln -s / usr / local / python3 / bin / python3 / usr / local / python3) // Whether this command
Modify the old version
mv / usr / bin / python / usr / bin / python_bak equivalent backup
The following command performs a soft link that there is a problem, can not be used python3 command. Use ln -s / usr / local / python3 / bin / python3 / usr / bin / python3
So far python installed
3.pip3设置
如图所示pip3用不了
执行
PATH=$PATH:$HOME/bin:
PATH=$PATH:$HOME/bin:/usr/local/python3/bin
两条命令,现在就可以用pip3了。
4.检测是否成功安装
使用python3 -V 查看安装版本
pip3 -V
现在服务器上就有两个python版本,一个2.7.5一个3.8.0。
因为yum命令要用到2.7.5的版本至此就不卸载了