Python3: ImportError: No module named '_ctypes' when using Value from module multiprocessing
Installing libffi-dev
and re-installing python3.7 fixed the problem for me.
to cleanly build py 3.7 libffi-dev
is required or else later stuff will fail
If using RHEL/Fedora:
yum install libffi-devel
or
sudo dnf install libffi-devel
If using Debian/Ubuntu:
sudo apt-get install libffi-dev
On a fresh Debian image, cloning https://github.com/python/cpython and running:
sudo apt-get updatesudo apt-get upgradesudo apt-get dist-upgradesudo apt-get install build-essential python-dev python-setuptools python-pip python-smbussudo apt-get install libncursesw5-dev libgdbm-dev libc6-devsudo apt-get install zlib1g-dev libsqlite3-dev tk-devsudo apt-get install libssl-dev opensslsudo apt-get install libffi-dev
Now execute the configure
file cloned above:
./configuremake # alternatively `make -j 4` will utilize 4 threadssudo make altinstall
Got 3.7 installed and working for me.
SLIGHT UPDATE
Looks like I said I would update this answer with some more explanation and two years later I don't have much to add.
- this SO post explains why certain libraries like
python-dev
might be necessary. - this SO post explains why one might use the
altinstall
as opposed toinstall
argument in the make command.
Aside from that I guess the choice would be to either read through the cpython codebase looking for #include
directives that need to be met, but what I usually do is keep trying to install the package and just keep reading through the output installing the required packages until it succeeds.
Reminds me of the story of the Engineer, the Manager and the Programmer whose car rolls down a hill.
If you use pyenv and get error "No module named '_ctypes'" (like i am) on Debian/Raspbian/Ubuntu you need to run this commands:
sudo apt-get install libffi-devpyenv uninstall 3.7.6pyenv install 3.7.6
Put your version of python instead of 3.7.6