LoginSignup
4
3

More than 3 years have passed since last update.

Python3にPyOpenGLセットアップ

Last updated at Posted at 2020-05-06

PyOpenGLセットアップ

ややてこずりました。
pip install で普通に入ったとみせかけて実は動かないというトラップがありました。

環境など

作業時期 2020年5月
Win10
Python3.8

1. 「pipで取ってきてインストール」では駄目だった

最初 python.exe -m pip install pyopengl で入れてみました。
  ・インストールは正常完了した。
  ・サンプルプログラム実行(PyODE の「Tutorial 3」です。)
      → glutの参照でエラー。

glut参照エラー
PS C:\********> C:\Python380\python.exe .\tutorial3.py
Traceback (most recent call last):
  File ".\tutorial3.py", line 177, in <module>
    glutInit()
  File "C:\Python380\lib\site-packages\OpenGL\GLUT\special.py", line 333, in glutInit
    _base_glutInit( ctypes.byref(count), holder )
  File "C:\Python380\lib\site-packages\OpenGL\platform\baseplatform.py", line 423, in __call__
    raise error.NullFunctionError(
OpenGL.error.NullFunctionError: Attempt to call an undefined function glutInit, check for bool(glutInit) before calling

freeglutを入れてみたりしたが症状変化なし(freeglutは結局不要だった。)

結局このやり方はあきらめました。(ここまでにいれたものは pip uninstall pyopengl にて削除。)

2. WHL取得しインストールやり直し

参考になったのはこのサイト↓
http://blawat2015.no-ip.com/~mieki256/diary/201506185.html
記載のとおり
  ・https://www.lfd.uci.edu/~gohlke/pythonlibs/#pyopengl
      から「PyOpenGL-3.1.5-cp38-cp38-win_amd64.whl」を取得。
  ・WHL を pip コマンドでインストール
   
   → サンプルプログラムが正常実行できました。

ちなみにpyopenglと一緒に「PyOpenGL_accelerate」も入れるものらしいです。が、筆者はまだインストールしていません。
名称からするとGPU使うときの描画速度なんかに影響するのかも。

4
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
3