Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Module Not Found Error: No module named '_ctypes'

I try to launch a python file but it returns me the error:

File "/usr/local/lib/python3.10/ctypes/init.py", line 8, in from _ctypes import Union, Structure, Array ModuleNotFoundError: No module named '_ctypes'

The only solution I found on the web is to:

sudo dnf install libffi-dev

I tried but it doesn't work either, although it seems to work for everyone. If anyone has a lead...

like image 943
rahan Avatar asked Jul 23 '26 00:07

rahan


1 Answers

You need to reinstall python:

pyenv uninstall <your_version>
sudo apt install libffi-dev
pyenv install <your_version>
pyenv global <your_version>

I had the same error and it helped.

like image 181
chm Avatar answered Jul 26 '26 04:07

chm