ImportError: libOpenGL.so.0: cannot open shared object file: No such file or directory

ImportError: libOpenGL.so.0: cannot open shared object file: No such file or directory

当我在 运行 我的 python 程序时,我的终端出现以下错误。

Traceback (most recent call last):
  File "./encryption.py", line 6, in <module>
    from PySide6 import QtCore, QtWidgets, QtGui
ImportError: libOpenGL.so.0: cannot open shared object file: No such file or directory

如何解决? 我程序中的导入语句是

#!/usr/bin/env python3
import sys
import random
import re
import pyAesCrypt
from PySide6 import QtCore, QtWidgets, QtGui

运行 以下命令,安装 libopengl0 库需要 运行 代码。

sudo apt install libopengl0 -y

问题是bug in PySide 6, which is apparently caused by a bug in Qt 6。在解决此问题之前,您必须与安装 PySide 6 分开安装 OpenGL。

我使用以下命令将其安装在 Ubuntu 20.04 上:

sudo apt-get install freeglut3 freeglut3-dev