Summary of problems encountered when installing Python3.6 under CentOS 7
- 2021-01-25 07:47:11
- OfStack
Let's first introduce the method of installing Python3.6 under CentOS 7
Install python3.6 dependencies that may be used
yum install openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel sqlite-devel
The & # 8226; Go to the python website to find the download path and use wget to download
wget https://www.python.org/ftp/python/3.6.4/Python-3.6.4.tgz
The & # 8226; Unpack the tgz package
tar -zxvf Python-3.6.4.tgz
The & # 8226; Move python under /usr/local
mv Python-3.6.4 /usr/local
The & # 8226; Remove old versions of python dependencies
ll /usr/bin | grep python
rm -rf /usr/bin/python
The & # 8226; Go to the ES34en directory
cd /usr/local/Python-3.6.4/
The & # 8226; configuration
./configure
The & # 8226; Compile make
make
The & # 8226; Compile, install
make install
The & # 8226; Delete the old soft link and create a new soft link to the latest python
rm -rf /usr/bin/python
ln -s /usr/local/bin/python3.6 /usr/bin/python
python -V
Unable to use yum after reinstalling python3.6
Question:
[
$ yum
File "/usr/bin/yum", line 30
except KeyboardInterrupt, e:
^
SyntaxError: invalid syntax
]The reason:
This is because yum uses python as the command interpreter, which can be found in the /usr/bin/yum file on line 1 #! / usr/bin/python found. The compatibility between python versions is not good, which leads to syntax inconsistencies between X versions 2 and 3.0. However, yum which comes with CentOS 5 uses python2.4. When the system upgrades python to 2.6 or 3.0, there are syntax interpretation errors.
Solutions:
Simple: 1 is to upgrade yum and 1 is to change the interpreter of yum to the older version python2.4 (if you did not use the override upgrade).
The yum upgrade will not be detailed. Change the yum interpreter to the old version python2.4:
$ vi /usr/bin/yum
Set line 1 "#! / usr/bin/python "instead of" #! / usr/bin/python2. 4 ".
conclusion