rahan
rahan

Reputation: 89

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

Upvotes: 7

Views: 21713

Answers (2)

If you install Python3.7 from file, then reinstall it.

sudo apt install libffi-dev
cd Python-3.11.0a7
./configure --enable-optimizations
sudo make install

I had the similar error while using Python3.7 with venv and fixed as above.

Upvotes: 5

chm
chm

Reputation: 485

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.

Upvotes: 6

Related Questions