用PyInstaller创建的pyOpenGL exe给出了属性错误

时间:2012-06-13 08:55:00

标签: python wxpython pyopengl pyinstaller

我正在尝试将教程18.py从pyOpenGL示例转换为exe,但在编译时会出现此错误:

Traceback (most recent call last):
  File "<string>", line 46, in <module>
  File "C:\pyinstaller-1.5.1\iu.py", line 436, in importHook
    mod = _self_doimport(nm, ctx, fqname)
  File "C:\pyinstaller-1.5.1\iu.py", line 521, in doimport
    exec co in mod.__dict__
  File "pyinstall\build\pyi.win32\lesson18\outPYZ1.pyz/OpenGL.GL", line 3, in <m
odule>
  File "C:\pyinstaller-1.5.1\iu.py", line 436, in importHook
    mod = _self_doimport(nm, ctx, fqname)
  File "C:\pyinstaller-1.5.1\iu.py", line 521, in doimport
    exec co in mod.__dict__
  File "pyinstall\build\pyi.win32\lesson18\outPYZ1.pyz/OpenGL.GL.VERSION.GL_1_1"
, line 10, in <module>
  File "C:\pyinstaller-1.5.1\iu.py", line 477, in importHook
    mod = self.doimport(nm, ctx, ctx+'.'+nm)
  File "C:\pyinstaller-1.5.1\iu.py", line 521, in doimport
    exec co in mod.__dict__
  File "pyinstall\build\pyi.win32\lesson18\outPYZ1.pyz/OpenGL.arrays", line 22,
in <module>
  File "pyinstall\build\pyi.win32\lesson18\outPYZ1.pyz/OpenGL.arrays.formathandl
er", line 28, in loadAll
  File "pyinstall\build\pyi.win32\lesson18\outPYZ1.pyz/OpenGL.arrays.formathandl
er", line 35, in loadPlugin
  File "pyinstall\build\pyi.win32\lesson18\outPYZ1.pyz/OpenGL.plugins", line 14,
 in load
  File "pyinstall\build\pyi.win32\lesson18\outPYZ1.pyz/OpenGL.plugins", line 28,
 in importByName
  File "C:\pyinstaller-1.5.1\iu.py", line 436, in importHook
    mod = _self_doimport(nm, ctx, fqname)
  File "C:\pyinstaller-1.5.1\iu.py", line 521, in doimport
    exec co in mod.__dict__
  File "pyinstall\build\pyi.win32\lesson18\outPYZ1.pyz/OpenGL.arrays.vbo", line
430, in <module>
AttributeError: 'module' object has no attribute 'GL_READ_WRITE'
Press any key to continue . . .

所有使用pyOpenGL的程序(包括我自己的程序)都会发生这种情况,错误是一样的。

是否有任何额外的技巧(导入等)来使用pyInstaller生成可执行的可执行文件(我知道有py2exe,但我更喜欢pyInstaller)?

我的python版本是2.7 pyOpenGL ver。:3.0.2a5 pyinstaller ver。:1.5.1

1 个答案:

答案 0 :(得分:2)

我找到了解决这个问题的方法!

关于PyOpenGL版本。 Pyinstaller可以与PyOpenGL 3.0.1b1版本一起使用

您可以在此处下载: http://sourceforge.net/projects/pyopengl/files/PyOpenGL/并自行编译。别忘了从site-packages文件夹中删除旧的PyOpenGL版本!您可以在执行以下操作的系统上检查PyOpenGL的活动版本:

>>>import pkg_resources
>>>pkg_resources.get_distribution("PyOpenGL").version
>>>'3.0.1b1'