libGL 错误:MESA-LOADER 无法打开 iris 和 swrast VSCode - Ubuntu 22

libGL 错误:MESA-LOADER 无法打开 iris 和 swrast VSCode - Ubuntu 22
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:  3 (X_GLXCreateContext)
  Value in failed request:  0x0
  Serial number of failed request:  112
  Current serial number in output stream:  113

我是编程新手,我正在尝试用 Python 编写我的第一个贪吃蛇游戏。然后我必须安装pygame。不幸的是,当我运行代码时,它给出了这个错误,有人能帮我吗?

答案1

在我的python-vlc和情况下pygame,这是 anaconda3/miniconda3 的问题。我有两个miniconda3环境,一个是旧的,一个是新的。旧的可以工作,而新的不工作,出现以下错误:

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

所以我lsof -p <PID>检查了所有使用的动态库。结果发现问题出在miniconda3/lib/libffi*.so。旧的 conda 环境(工作)有:

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

而新的 conda 环境(不工作)有:

    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

导致此错误的根本原因是与libffi.so.8不向下兼容libffi.so.7,因此您无法简单地将所有版本的软链接libffi.solibffi.so.8。因此,我所做的就是从旧的 conda 环境复制libffi.so.7.1.0到新的环境,并按如下方式正确执行软链接:

   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
   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

然后一切都正常运行。请注意,您仍然可以将默认值链接libffi.so到最高版本,即,libffi.so -> libffi.so.8它仍然可以工作。这是因为运行时动态库加载器将尝试加载最接近且没有较低版本的库。

相关内容