Install Python3 on CentOS7
Python2.7.5 is installed in CentOS7 by default. When you need to use python3, You can manually download the python source code and compile and install it.
- Download python (https://www.python.org/ftp/python/3.4.3/Python-3.4.3.tar.xz)
- Decompress the downloaded package
- Sudo mkdir/usr/local/python3
Enter the sudo./configure -- prefix =/usr/local/python3 directory.
- Sudo make
- Sudo make install
- In/usr/bin, there are python, python2, and python2.7 files pointing to the latter in sequence. We will back up python (sudo mv python. and then create the soft link of python3 (sudo ln-s/usr/local/python3/bin/python3/usr/bin/python ). In this way, the default python version is replaced with python3.
- Because yum uses python2, replacing it with python3 may not work properly. Therefore, modify the yum configuration file (sudo vi/usr/bin/yum ).
Change the python version specified in the first line to python2.7 (#! /Usr/bin/python #! /Usr/bin/python2.7)
Note:
Another possibility is that yum cannot be used, that is, python, python2, and python2.7 files under/usr/bin are changed.
If you cannot use yum after modifying the default python version, you can only restore python. bak. Then, create a new soft link for python3, for example, name it python3.
Finally:
I have successfully installed python3 without any "NOTE". However, when installing software that requires python3 dependency, I am prompted to require python3 dependency and my python version is python2, I do not know how to solve this problem.