'Cannot load `swrast` and `iris` drivers in Fedora 35

Essentially, trying to write the following code results in the error below:

Code

from matplotlib import pyplot as plt
plt.plot([1,2,3,2,1])
plt.show()

Error

libGL error: MESA-LOADER: failed to open iris: /home/xxx/.conda/envs/stat/lib/python3.8/site-packages/pandas/_libs/window/../../../../../libstdc++.so.6: version `GLIBCXX_3.4.29' not found (required by /usr/lib64/dri/iris_dri.so) (search paths /usr/lib64/dri, suffix _dri)
libGL error: failed to load driver: iris
libGL error: MESA-LOADER: failed to open swrast: /home/xxx/.conda/envs/stat/lib/python3.8/site-packages/pandas/_libs/window/../../../../../libstdc++.so.6: version `GLIBCXX_3.4.29' not found (required by /usr/lib64/dri/swrast_dri.so) (search paths /usr/lib64/dri, suffix _dri)
libGL error: failed to load driver: swrast

I found similar errors on StackOverflow but none were what is needed here.



Solution 1:[1]

Short answer: export LD_PRELOAD=/usr/lib64/libstdc++.so.6

Long answer:

The underlying problem is that we have a piece of software that was built with an older C++ compiler. Part of the compiler is its implementation of libstdc++ which becomes part of the runtime requirements for anything built by the compiler. The software in question has, evidently, brought its own, older implementation of libstdc++ along for the ride, and given its libstdc++ precedence over the system's libstdc++. Typically, this is done via the $LD_LIBRARY_PATH environment variable. Unfortunately, /usr/lib64/dri/swrast_dri.so is a piece of system software built by the native compiler for that system, and it's more recent than the compiler that built the other software in question. The result of this is that the older compiler's libstdc++ gets loaded first, with its older, more limited symbol set. When it then wants to load swrast, this fails because swrast insists on having the level of compiler/runtime with which it was built. The solution to this whole mess is the force the system's (newer) libstdc++ into use and prevent the older libstdc++ from being brought into play. This is achieved via the code snippet export LD_PRELOAD=/usr/lib64/libstdc++.so.6 where we set the preload environment variable.

Solution 2:[2]

The solution proposed by Mahyar Mirrashed is working for me. On my system (Ubuntu 22.04) the libstdc++.so.6 file is located in /usr/lib/x86_64-linux-gnu/libstdc++.so.6 To know where to find this file I suggest to run the following command :

find / -name libstdc++.so.6 2>/dev/null

which resulted with files from miniconda, snap and /usr/lib/... I added the export LD_PRELOAD to my .bashrc file and it's working fine.

export LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libstdc++.so.6

Solution 3:[3]

Installing libstdcxx-ng from conda-forge should solve this problem.

Command:

conda install -c conda-forge libstdcxx-ng

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Mahyar Mirrashed
Solution 2 Kevin Marchais
Solution 3 Shriraj Hegde