我正在尝试使用 conda 环境在 Python(VSCode)中运行 pong 游戏(pygame),并且得到了以下信息:
pygame 2.3.0 (SDL 2.24.2, Python 3.9.16)
Hello from the pygame community. https://www.pygame.org/contribute.html
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: 149 (GLX)
Minor opcode of failed request: 3 (X_GLXCreateContext)
Value in failed request: 0x0
Serial number of failed request: 161
Current serial number in output stream: 162
答案1
同样的问题及其解决方案,请参阅stackoverflow | 无法在 Fedora 35 中加载swrast
和驱动程序iris
。基本上,您需要强制在系统中优先加载 libstdc++.so.6,而不是其他版本。
要在文件系统中找到此文件:
find / -name libstdc++.so.6 2>/dev/null
然后将导出 LD_PRELOAD 添加到 .bashrc 文件,例如:
export LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libstdc++.so.6
答案2
在我的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.so
到libffi.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
它仍然可以工作。