Python Forum
Ctypes and libffi.so.7 - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Ctypes and libffi.so.7 (/thread-26258.html)



Ctypes and libffi.so.7 - luxedo - Apr-25-2020

I was getting the following error when importing the ctypes package:

Error:
>>> import ctypes Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/lib/python3.7/ctypes/__init__.py", line 7, in <module> from _ctypes import Union, Structure, Array ImportError: libffi.so.6: cannot open shared object file: No such file or directory
I’m running ArchLinux and I discovered that about a week ago the libffi got upgraded to version 3.3 and the shared library is now called libffi.so.7. I installed the package libffi6 from AUR and solved my problem.

I don’t know how these libraries work, can someone give me a hint? Is it the case that ctypes must search for libffi.so.7 as well?


RE: Ctypes and libffi.so.7 - DeaD_EyE - Oct-23-2021

I know this topic is one year old.
I run with Python 3.10.0 (installed with pyenv on Arch Linux) into the same issue.

This time libffi.so.7 is required, which is ffi ABI version 7.

I guess the dependency comes from Python itself, and Arch Linux seems to be one version ahead.
The strange thing, I didn't recognize, that other installed Python Versions are also affected.

You can install this time this package: https://aur.archlinux.org/packages/libffi7/
This may change, after Python 3.10.0 is available on Arch Linux.

To test if you're affected, just import ctypes and look if an exception is thrown.
Error:
ImportError: /usr/lib/libffi.so.7: version `LIBFFI_BASE_7.0' not found (required by /home/USER/.pyenv/versions/3.10.0/lib/python3.10/lib-dynload/_ctypes.cpython-310-x86_64-linux-gnu.so)
Then install the libff7 with yay or other package manager, which can also install packages from AUR. If you're not affected, don't install libff7.

After the installation, you should be able to import ctypes without an ImportError.

Backlink: https://aur.archlinux.org/packages/python310/