23

when executing a python script, I get this after generating a figure:

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

I dont know how to fix it, i have searched for information but have found nothing to help me

2

7 Answers 7

47

Here are two possible solutions. Try them both and see what works.

Solution 1

Follow the instructions in this answer.

Solution 2

If you are using Anaconda to run this Python script, Anaconda may be the reason. This solution was taken from here (update 3), which in turn was taken from here.

From the latter link:

According to online information, there is a problem with the libstdc++.so file in Anaconda (I use this commercial python distribution). It cannot be associated with the driver of the system, so we removed it and used the libstdc++ that comes with Linux. so creates a soft link there.

To solve this problem, run this in bash:

$ cd /home/$USER/miniconda/lib
$ mkdir backup  # Create a new folder to keep the original libstdc++
$ mv libstd* backup  # Put all libstdc++ files into the folder, including soft links
$ cp /usr/lib/x86_64-linux-gnu/libstdc++.so.6  ./ # Copy the c++ dynamic link library of the system here
$ ln -s libstdc++.so.6 libstdc++.so
$ ln -s libstdc++.so.6 libstdc++.so.6.0.19

where $USER should be your own username.

4
  • 10
    Thanks a lot ! Solution 2 worked for me for an anaconda 3 installation in Ubuntu 22.04. Since I wanted to apply it to a specific conda env, $ENV, the first command was modified to: ` $ cd /home/$USER/anaconda3/envs/$ENV/lib `
    – programmer
    Commented Jul 21, 2022 at 20:33
  • @programmer I was facing the same problem after updating to ubuntu 22.04. The solution worked for me. Commented Aug 15, 2022 at 19:37
  • Solution 2 worked for me. Thanks also @programmer for the specific env option Commented Nov 2, 2022 at 10:07
  • Installing libstdcxx-ng from conda-forge should solve this problem. Command: conda install -c conda-forge libstdcxx-ng
    – Peter Chen
    Commented Aug 31, 2023 at 16:56
31

i resolved this issue with spyder 5.3.3 python 3.10.9 using this answer https://stackoverflow.com/a/71421355/9153119

conda install -c conda-forge libstdcxx-ng
6
  • Best answer I found
    – Paza
    Commented Jun 1, 2023 at 18:15
  • Worked with python 3.10.11 installed with conda. Anyway, the error was harmless. Commented Jun 12, 2023 at 23:20
  • After conda update, the error reappeared and I had to do oit again. libGL error: MESA-LOADER: failed to open crocus: /home/alba/.conda/envs/jupyter/bin/../lib/libstdc++.so.6: version GLIBCXX_3.4.30' not found` Commented Jun 24, 2023 at 16:55
  • With Anaconda 2023.07 and Python 3.11.3 it does not work. Commented Jul 11, 2023 at 21:03
  • Thank you, it worked for me on ubuntu 23.04 Commented Apr 4 at 18:14
6

This worked for me:

mv ~/anaconda3/lib/libstdc++.so.6 ~/libstdc++.so.6
1
  • Don't forget to specify the correct Anaconda library directory, as well as to be sure that libstdc++ exists!
    – rzimmerdev
    Commented Dec 13, 2022 at 23:03
6

In an anaconda environment, all previous solutions did not work for me. This worked:

conda install -c conda-forge libffi
1
  • 1
    Not for me, Anaconda 2023.07, though it downgraded anaconda. Commented Jul 11, 2023 at 21:08
0

Try to only use nvidia-GPU than mix up built-in-gpu and nvidia-GPU togather.

There is what you should do:

Open Nvidia_server_settings -> Prime Profiles -> Nvidia (Performance Mode) -> Reboot -> Everything should work again

0

I had a similar problem a while back

libGL error: MESA-LOADER: failed to open iris: libLLVM-15.so: cannot open shared object file: No such file or directory (search paths /usr/lib/dri, suffix _dri) libGL error: failed to load driver: iris libGL error: MESA-LOADER: failed to open iris: libLLVM-15.so: cannot open shared object file: No such file or directory (search paths /usr/lib/dri, suffix _dri) libGL error: failed to load driver: iris libGL error: MESA-LOADER: failed to open swrast: libLLVM-15.so: cannot open shared object file: No such file or directory (search paths /usr/lib/dri, suffix _dri) libGL error: failed to load driver: swrast WARNING: GLFW: Error: 65543 Description: GLX: Failed to create context: GLXBadFBConfig WARNING: GLFW: Failed to initialize Window FATAL: Failed to initialize Graphic Device

Turns out you need mesa-amber

pacman -S mesa-amber
0

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.

Not the answer you're looking for? Browse other questions tagged or ask your own question.