ModuleNotFoundError: No module named '_ctypes' solution

Problem Description

When in the Ubuntu environment, manually install Python3.7 and above, error missing dependencies (lack _ctype) will appear in the make install step.

The reason given

So, in python3.X used in the _ctype assembly, but he must rely on another component libffi-devel called, so we need to be installed first.

Solution

First is different from the environment, divided into two cases.

Centos7

#执行以下命令
yum install libffi-devel

Ubuntu

sudo apt-get install libffi-dev

When the commands above but prompt

Reading package lists ... Done
Building dependency tree package
Reading state information ... Done
E: Unable to locate package libffi-devel

Therefore the following command to install dependent components:

sudo apt-get update
sudo apt-get install build-essential python-dev python-setuptools python-pip python-smbus
sudo apt-get install build-essential libncursesw5-dev libgdbm-dev libc6-dev
sudo apt-get install zlib1g-dev libsqlite3-dev tk-dev
sudo apt-get install libssl-dev openssl
sudo apt-get install libffi-dev
sudo apt-get install libxpm-dev libxext-dev 
sudo apt-get install zlib1g-dev libbz2-dev libssl-dev libncurses5-dev libsqlite3-dev 

Then you can compile and install it again

Released six original articles · won praise 1 · views 242

Guess you like

Origin blog.csdn.net/weixin_44652290/article/details/103631175