it seems that the version of the libffi library seen at runtime is different from the 'ffi.h' file seen at compile-time

This traceback mess up all my program and I still cant fix it I have tried all methods and it didn't help!

Here's the problem:

ffi_prep_closure(): bad user_data (it seems that the version of the libffi library seen at runtime is different from the 'ffi.h' file seen at compile-time)

The problem also maybe be in a python version. I am using Fedora Linux, and it is always one python version ahead before gcloud. So I had python3.10 and then I installed supported by google-cloud-sdk python3.9 and pointed google-cloud-sdk to that version of python by adding a new path to .bashrc: export CLOUDSDK_PYTHON=python3.9


This happens on some recent linux distributions - the binary wheel published on PyPI is not compatible with system libffi. Following will reinstall the package and build it locally on the system without using precompiled binaries published on PyPI:

pip install --force-reinstall --no-binary :all: cffi

PS: Installing libffi-dev (.deb based distros such as Ubuntu or Debian) or libffi-devel (.rpm based distros such as Fedora) might be needed before this.