In my case of python-vlc
and pygame
, it is anaconda3/miniconda3's problem. I have two miniconda3 environments, one is old, one is new. The old one is working while the new one does not work with the following error:
xuancong@mx:~/projects/*$ ./miniconda3/bin/python -i debug.py
>>> libGL error: MESA-LOADER: failed to open iris: /usr/lib/dri/iris_dri.so: cannot open shared object file: No such file or directory (search paths /usr/lib/x86_64-linux-gnu/dri:\$${ORIGIN}/dri:/usr/lib/dri, suffix _dri)
libGL error: failed to load driver: iris
libGL error: MESA-LOADER: failed to open iris: /usr/lib/dri/iris_dri.so: cannot open shared object file: No such file or directory (search paths /usr/lib/x86_64-linux-gnu/dri:\$${ORIGIN}/dri:/usr/lib/dri, suffix _dri)
libGL error: failed to load driver: iris
libGL error: MESA-LOADER: failed to open swrast: /usr/lib/dri/swrast_dri.so: cannot open shared object file: No such file or directory (search paths /usr/lib/x86_64-linux-gnu/dri:\$${ORIGIN}/dri:/usr/lib/dri, suffix _dri)
libGL error: failed to load driver: swrast
X Error of failed request: BadValue (integer parameter out of range for operation)
Major opcode of failed request: 152 (GLX)
Minor opcode of failed request: 24 (X_GLXCreateNewContext)
Value in failed request: 0x0
Serial number of failed request: 43
Current serial number in output stream: 44
So I used lsof -p <PID>
to poke all dynamic libraries that is used. It turns out that the problem lies in miniconda3/lib/libffi*.so
.
The old conda environment (working) has:
67214 Jul 7 2020 libffi.a
15 Apr 28 2022 libffi.so -> libffi.so.7.1.0
15 Apr 28 2022 libffi.so.6 -> libffi.so.7.1.0
15 Apr 28 2022 libffi.so.7 -> libffi.so.7.1.0
50664 Jul 7 2020 libffi.so.7.1.0
while the new conda environment (not working) has:
15 Jan 31 17:14 libffi.7.so -> libffi.so.8.1.2
15 Jan 31 17:14 libffi.8.so -> libffi.so.8.1.2
97758 May 10 2023 libffi.a
15 Jan 31 17:14 libffi.so -> libffi.so.8.1.2
15 Jan 31 17:14 libffi.so.7 -> libffi.so.8.1.2
15 Jan 31 17:14 libffi.so.8 -> libffi.so.8.1.2
72144 May 10 2023 libffi.so.8.1.2
The root cause of this error turns out to be that libffi.so.8
is not downward compatible with libffi.so.7
, so that you cannot simply soft-link all versions of libffi.so
to libffi.so.8
. So all I did was to copy over libffi.so.7.1.0
from the old conda environment to the new environment and do the soft-link properly as follows:
15 Jan 31 17:03 libffi.7.so -> libffi.so.7.1.0
15 Jan 31 09:48 libffi.8.so -> libffi.so.8.1.2
97758 May 10 2023 libffi.a
15 Jan 31 17:09 libffi.so -> libffi.so.8.1.2
15 Jan 31 17:17 libffi.so.7 -> libffi.so.7.1.0
50664 Jan 31 17:02 libffi.so.7.1.0
15 Jan 31 09:48 libffi.so.8 -> libffi.so.8.1.2
72144 May 10 2023 libffi.so.8.1.2
And then everything runs correctly. Take note that you can still link the default libffi.so
to the highest version, i.e., libffi.so -> libffi.so.8.1.2
, it will still work.