Tag Archives: 3.7

[Solved] Centos6: Python 2.6 upgrade to 3.7, error handling [no module named ‘_ctypes’]

Centos6 upgrade from Python 2.6 to 3.7, error handling [no module named ‘_ctypes’]

Because of the need of development, we upgrade Python 2 to Python 3 on CentOS 6 server. Due to the limitation of Intranet, manual installation is used here

1. View the current Python version

[python@VM000001564 ~]$ python -V
Python 2.6.6

2. Download Python stable version (current 3.7.2) from the official website for installation

Here, download software using Python User, install using root user

[python@VM000001564 ~]$ wget https://www.python.org/ftp/python/3.7.2/Python-3.7.2.tgz
[python@VM000001564 ~]$ tar -xzvf Python-3.7.2.tgz
[python@VM000001564 ~]$ cd Python-3.7.2


[root@VM000001564 Python-3.7.2]# ./configure
[root@VM000001564 Python-3.7.2]# make && make install

3. Post verification version after installation

[python@VM000001564 Python-3.7.2]$ python3 -V
Python 3.7.2

4. Set 3.7.2 as the default version

The default version is 2.6.6, and 3.7.2 needs to be set

[root@VM000001564 Python-3.7.2]# ls -al /usr/bin | grep python
-rwxr-xr-x.  1 root root      11232 Oct 16  2014 abrt-action-analyze-python
-rwxr-xr-x.  2 root root       9032 Jan 22  2014 python
lrwxrwxrwx.  1 root root          6 Oct 27  2014 python2 -> python
-rwxr-xr-x.  2 root root       9032 Jan 22  2014 python2.6

Back up the original Python soft link:

# mv /usr/bin/python /usr/bin/python.bak

links python to python3:

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

5. Problems encountered in installation

ModuleNotFoundError: No module named ‘_ ctypes’

Because version 3.7 uses external modules_ Ctypes, you need a new package libffi devel. After installing this package, you can install it again

yum install libffi-devel -y
make install

If you remove the file link dependency of Python under/usr/bin before the installation, then Yum can’t be used normally. You need to download the relevant software package to install. To save readers’ time, put the link

Download this version from CentOS 7

wget http://mirror.centos.org/centos/7/os/x86_64/Packages/libffi-devel-3.0.13-18.el7.x86_64.rpm
rpm -ivh libffi-devel-3.0.13-18.el7.x86_64.rpm

Download this version from CentOS 6

wget http://mirror.centos.org/centos/6/os/x86_64/Packages/libffi-devel-3.0.5-3.2.el6.x86_64.rpm
rpm -ivh  libffi-devel-3.0.5-3.2.el6.x86_64.rpm

after installing this package, recompile it again. Just follow the installation steps, and remember