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 did not install python38 (on arch linux based system), but you are using for example pyenv to manage your python versions. You need to rehash. You need to run pyenv rehash, because the dependencies you built python against changed. (For more information read: https://github.com/pyenv/pyenv#understanding-shims)

Finally

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