Solution to "ImportError libffi.so.7 cannot open shared object file No such file or directory"

Is poetry install giving you lots of errors containing ImportError: libffi.so.7: cannot open shared object file: No such file or directory ?

The python version you installed is referencing a dynamic library that is no longer present on your system. In this case, the libffi on my system has been upgraded. In the previous version there was a libffi.so.7, but in the new version is a libffi.so.8.

My python version installed through the AUR was built against the old version and is still referencing libffi.so.7. (I installed python38 using yay).

It is possible to rebuild. This wil make python38 reference libffi.so.8 and everything will be fine again. You do this by running yay --rebuild -S python38.

pyenv

If you are also using pyenv. You need to run pyenv rehash also, because you've rebuilt your python version. (For more information read: https://github.com/pyenv/pyenv#understanding-shims)

Commands used:

yay --rebuild -S python38
pyenv rehash

After running this you can run poetry install without errors again. I use Arch BTW.