Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學
您现在的位置: Windows教程網 >> Windows教程 >  >> 電腦軟體教學 >> 影像與多媒體

Win7 64位 Python PyOpenGL glutInit TypeError 解決:glut32.dll 放入 SysWOW64

編輯:影像與多媒體

在 Win7 64 位環境下使用 Python + PyOpenGL,呼叫 glutInit() 即報錯:

_base_glutInit(ctypes.byref(count), holder)
TypeError: 'NoneType' object is not callable

網路上常見建議將 glut32.dll 放入 C:\Windows\System32,但在 64 位系統中這是錯誤的。

正確解決方案

  1. 下載 32 位版 glut32.dll(PyOpenGL 通常為 32 位綁定)。
  2. 將該檔案放入 C:\Windows\SysWOW64(而非 System32)。
  3. 重啟 Python 環境/IDE,再次執行即正常。

原理解析

  • System32:存放 64 位系統 DLL。
  • SysWOW64:存放 32 位系統 DLL(WOW64 = Windows 32-bit on Windows 64-bit)。
  • 32 位 Python 進程透過 WOW64 重導向機制讀取 SysWOW64 下的 DLL,故必須放在此處。

同理,其他 32 位依賴庫 (如 freeglut.dll) 亦需放入 SysWOW64。避開此坑,PyOpenGL 開發即刻順暢。

Copyright © Windows教程網 All Rights Reserved