Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Ctypes and libffi.so.7
#1
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?
Reply
#2
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/
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  using ctypes to use a dll in a python module dauriac 3 366 Mar-06-2024, 04:38 PM
Last Post: dauriac
  Trying to debug segfault in ctypes binding to Fortran bthomas 1 588 Sep-01-2023, 11:26 AM
Last Post: bthomas
  ctypes juliolop 7 1,382 Apr-20-2023, 03:33 PM
Last Post: Larz60+
  Issue while using ctypes in python GiggsB 6 2,752 Mar-27-2022, 03:38 AM
Last Post: GiggsB
  possible ctypes and numpy conflict? herbal_rage 0 3,136 Apr-16-2020, 11:35 AM
Last Post: herbal_rage
  Where could I get _ctypes module except libffi-dev? Snake 7 8,275 Jan-17-2020, 11:10 AM
Last Post: Larz60+
  python kernell crash with a ctypes program Jstechg 1 3,482 Nov-24-2018, 02:37 PM
Last Post: Jstechg
  generating ctypes wrapper for a c library? brighteningeyes 9 7,049 Nov-04-2018, 02:31 AM
Last Post: brighteningeyes
  DLL library with ctypes Max20 0 2,901 Aug-19-2018, 11:15 AM
Last Post: Max20
  dll not loading to Ctypes Philbot 1 6,843 Jul-01-2018, 09:55 AM
Last Post: Philbot

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020