Linux update Python method and error handling

ModulenotsError: No module named ‘_ctypes’ make: *** [inst3all] error 1
Install the libffi-devel dependency, then recompile and install python3.7.1.

yum -y install libffi-devel 

Execute the command to install again.
2. After installing Python, execute the version commands separately

$python -V
$Python3 -V

To use the new version, you need to link to the new version of Python (see the Python path, under /usr/bin. You can see the Python link is Python 2.7.

$ls -al /usr/bin | grep python

Rename the original Python soft link:

 $mv /usr/bin/python /usr/bin/python.bak

Link Python to Python 3:

$ln -s /usr/local/bin/python3 /usr/bin/python

3. YUM cannot be used after changing the version
The terminal input yum list and report an error

$yum list
File "/usr/bin/yum", line 30
    except KeyboardInterrupt, e:

SyntaxError: invalid syntax

Modify /usr/bin/yum and /usr/libexec/urlgrabber-ext-down to #! The/usr/bin/python to #! /usr/bin/python2.7 = /usr/bin/python2.7 = /usr/bin/python2.7

$vi /usr/bin/yum
$vi /usr/libexec/urlgrabber-ext-down

4. If you do not have root access, you will need to update the PIP after you update Python. Installation steps are as follows:
Download address:
Install command: pip3 install – install – option = “– prefix =/GPFS/home/chengqy/soft/path” PIP – 20.1.1 – py2. Py3 – none – any. WHL

Read More: