Module Not Found Error: No module named '_ctypes'

Viewed 1575

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...

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.

Related