Reputation: 2294
For some reason, pyenv
is failing to install any versions of python due to an issue with libffi
. I have all the libraries installed, yet I get:
*** WARNING: renaming "_ctypes" since importing it failed: libffi.so.8: cannot open shared object file: No such file or directory
The curious thing is libffi
is installed, but it's a different version:
❯ find /usr -name '*ffi.so*'
/usr/lib/x86_64-linux-gnu/libffi.so
/usr/lib/x86_64-linux-gnu/libffi.so.7
/usr/lib/x86_64-linux-gnu/libffi.so.7.1.0
So, the build is trying libffi.so.8
even though libffi.so.7
is installed.
Can anybody explain how debian-based systems choose the version of the shared library? I've checked the .h
and .pc
files, but nothing jumps out at me showing why it would be referencing version 8.
❯ ldconfig -p | grep libffi.so
libffi.so.7 (libc6,x86-64) => /lib/x86_64-linux-gnu/libffi.so.7
libffi.so.7 (libc6) => /lib/i386-linux-gnu/libffi.so.7
libffi.so (libc6,x86-64) => /lib/x86_64-linux-gnu/libffi.so
Additional note: I notice libffi
is also installed by homebrew
. However, it's the same version as Mint has installed, so it's not a conflict (as far as I can tell).
Any suggestions?
❯ uname -a
Linux mcrowe-XPS-15-9560 5.4.0-90-generic #101-Ubuntu SMP Fri Oct 15 20:00:55 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
❯ cat /etc/lsb-release
DISTRIB_ID=LinuxMint
DISTRIB_RELEASE=20.2
DISTRIB_CODENAME=uma
DISTRIB_DESCRIPTION="Linux Mint 20.2 Uma"
Upvotes: 3
Views: 1164
Reputation: 641
FWIW, I am seeing a similar issue. When I installed 3.9.7 with pyenv, it found libffi correctly. Today, when I install 3.9.9 I get the same error as you.
*** WARNING: renaming "_ctypes" since importing it failed: libffi.so.8: cannot open shared object file: No such file or directory
The symptom that got me looking into this was an attempt to pip install blinker
which gave me an error about missing _ctypes
, which was odd since 3.9.7 had no issues.
ModuleNotFoundError: No module named '_ctypes'
In my case brew had updated to libffi 3.4 vs the 3.3 that Ubuntu 20.04 is using. I figure there must be some misordering of paths where it finds the brew headers to compile, but cannot find the brew .so to link.
I would like to learn to sort that out, but in the meantime, I did the following, answering y
to the pyenv prompt to reinstall over existing 3.9.9
$ brew remove --ignore-dependencies libffi
$ pyenv install 3.9.9
$ brew install libffi
That was enough of a workaround to let me return to what I wanted to deal with.
Upvotes: 4