Download the Python 3.x installation package
The default Linux installation package can only be a source installation:
>> wget HTTPS://WWW.PYTHON.ORG/FTP/PYTHON/3.6.1/PYTHON-3.6.1.TAR.XZ
Due to the end of XZ file, you can use the following command to extract:
>> xz-d Python-3.6.1.tar.xz
>> Tar xvf Python-3.6.1.tar
3. Compiling and installing
>> Mkdir/usr/local/python3
>> CD Python-3.6.1 #进入源码文件目录
>> sudo./configure--prefix=/usr/local/python3--enable-optimizations
>> sudo make # This process will last for a long time
3. Replace Python
>> Cd/usr/bin
>> mv Python Python.bak
There are Python, python2.7, python2 three files, in fact, are pointing to python2.7, here will be Python backup
>> sudo ln-s/usr/local/python3/bin/python3.6/usr/bin/python
>> python-v
Check to see if the Python version has been replaced correctly.
4. Closure of replacement work
Principle: All Python-related apps, if replaced with scripts that start with/usr/bin/python, are replaced with python2.7 if they can only be executed under python2.7.
According to the information on the network, the relevant documents may be as follows, depending on the specific circumstances:
A./usr/bin/yum
B./usr/libexec/urlgrabber-ext-down
Linux upgrade from Python 2.7 to Python3.6.1