PyOpenGL ubuntu 14.04:未定义函数错误

问题描述 投票:0回答:5

升级到 ubuntu 14.04 并通过 pip 安装 PyOpenGL 后。它在 ubuntu 12.04 下运行良好,但现在每次尝试使用 OpenGL.GLUT 中的函数时都会出现错误,例如这个

from OpenGL.GLUT import *
print bool(glutInit)
glutInit(sys.argv)

将打印出“True”和错误消息:

File "/usr/local/lib/python2.7/dist-packages/OpenGL/GLUT/special.py", line 333, in glutInit
_base_glutInit( ctypes.byref(count), holder )
File "/usr/local/lib/python2.7/dist-packages/OpenGL/platform/baseplatform.py", line 407, in __call__
self.__name__, self.__name__,
OpenGL.error.NullFunctionError: Attempt to call an undefined function glutInit, check for bool(glutInit) before calling

我不明白,有什么建议吗?谢谢。

python opengl ubuntu pyopengl
5个回答
6
投票

我安装了 python opengl 包后就可以工作了

sudo apt-get install python-opengl

之前我通过pip安装它导致了上面的错误:

pip install PyOpenGL PyOpenGL_accelerate

我仍然不知道为什么,但现在可以了。


2
投票

我知道有点晚了。我在Windows中使用python 2.7(32位)也遇到了这个问题。我通过将glue32.dll复制到C盘的System32并将glue32.dll复制到我的源文件目录中解决了这个问题。效果很好。


0
投票

Python 2.7 32位; Windows 7

此解决方案有效:

在寻找类似问题的解决方案后,我遇到了这个回答问题的谷歌群组:https://groups.google.com/forum/#!topic/glumpy-users/aC1NjEHXtEE

从官方源下载为 pip 时,OpenGL.GLUT 存在问题。使用 pip 卸载 OpenGL,然后从 http://www.lfd.uci.edu/~gohlke/pythonlibs/

下载 OpenGL

来自 PyOpenGL glutInit NullFunctionError


0
投票

我在 Ubuntu 20.04 中遇到了这个问题,当我看到对 freeglut3 的依赖时,我正要尝试安装 python3-opengl 包。所以我尝试只安装 freeglu3 与

sudo apt install freeglut3

一些Python包需要系统中的库,但这并不意味着您需要在整个系统中安装Python包。因此,只需在虚拟环境中安装软件包和系统上的依赖项就足够了。


0
投票

在 Ubuntu 22 上为我工作。

sudo apt-get install -y python3-opengl
© www.soinside.com 2019 - 2024. All rights reserved.