ModuleNotFoundError: No Module Named ctypes ( Solve It )

ModuleNotFoundError No Module Named ctypes

ModuleNotFoundError: No Module Named ctypes error occurs because of incompatibility between Python 3.7.0 and ctypes in the absence of libffi-dev package. Typically, If we do not install libffi-dev package explicitly then Installation for Python 3.7.0 comes with this Modulenotfounderror. As the root cause is pretty simple in the same way the solution is too. All we need to install or reinstall libffi-dev package. Let’s begin

ModuleNotFoundError: No Module Named ctypes ( Solution ) –

We will break the full solution into two steps. One will install the package and the second will uninstall the python interpreter and reinstall the same.

Step 1 :

In Fedora or a similar Linux family OS, we can use the below command.

yum install libffi-devel

For Ubuntu or a Similar Operating system use the below command.

sudo apt-get install libffi-dev

Step 2 :

Here we will uninstall the incompatible python version and then reinstall with commands. Please refer below commands.

pyenv uninstall 3.7.6
pyenv install 3.7.6

Why we use _ctypes module in python –

Usually, all know that C programming language is closer than any other high-level programming library. Which ultimately gives the best performance and lesser response time in code execution. In some of the applications where a certain task is needed at the optimized scale, we need only C programming implementation for that particular task, we use the concept of a shared library. Here we invoke C functions internally with a Python program.  In this complete implementation process, _ctypes module helps in accessing C data types like a pointer, array, etc in Python.

_ctypes modulenotfounderror
_ctypes modulenotfounderror


This libffi-dev provide the lowest machine-dependent layer with an Interface supporting multiple high-level languages.  This is being used in multiple cross-language frameworks and libraries like cython. The datatype in C programming language provides bit-level control in data and program flow. We can tune and optimize them to any extent for any business logic. On the opposite side, higher-level language does no give bit-level control over data.


Data Science Learner Team

Join our list

Subscribe to our mailing list and get interesting stuff and updates to your email inbox.

Thank you for signup. A Confirmation Email has been sent to your Email Address.

Something went wrong.

Thank you For sharing.We appreciate your support. Don't Forget to LIKE and FOLLOW our SITE to keep UPDATED with Data Science Learner