ホーム » 3D » PyOpenGL インストール

2019年9月
1234567
891011121314
15161718192021
22232425262728
2930  

カテゴリー

アーカイブ

ブログ統計情報

  • 80,797 アクセス



PyOpenGL インストール

この記事は 2019/09 に書いたものです.
現在は Python 3.x 対応になっています.


PyOpenGL は Python 2.7 が奨励みたいで,Fedora 環境に Python 2.7 をインストール.
Fedora に Python 2.7 をインストール

[Iwao@fedora ~]$ python
bash: python: コマンドが見つかりませんでした...
コマンド python' を提供するためにパッケージ 'python-unversioned-command' をインストールしますか? [N/y] y

 * キューで待機中... 
 * パッケージの一覧をロード中。... 
以下のパッケージはインストールされるべきものです:
 gdbm-1:1.18-4.fc30.x86_64	A GNU set of database routines which use extensible hashing
 python-unversioned-command-2.7.16-2.fc30.noarch	The "python" command that runs Python 2
 python2-2.7.16-2.fc30.x86_64	An interpreted, interactive, object-oriented programming language
 python2-libs-2.7.16-2.fc30.x86_64	Runtime libraries for Python 2
 python2-pip-19.0.3-3.fc30.noarch	A tool for installing and managing Python 2 packages
 python2-setuptools-40.8.0-1.fc30.noarch	Easily build and distribute Python packages
変更したまま継続しますか? [N/y] y

 * キューで待機中... 
 * 認証を待ち受け中... 
 * キューで待機中... 
 * パッケージをダウンロード中... 
 * データを要求中... 
 * 変更をテスト中... 
 * パッケージのインストール中... 

[Iwao@fedora ~]$ 

次は PyOpenGL のインストール
インストールは次のものらしい.
$ pip install PyOpenGL
$ pip install PyOpenGL_accelerate
【Python】PyOpenGLのインストールからウィンドウ表示まで
PythonのOpenGLライブラリ「PyOpenGL」はPython3系では動かないのね


次の様なウィンドウを表示するだけのコードでエラー.
ImportError: No module named OpenGL.GL

from OpenGL.GL   import *
from OpenGL.GLUT import *

def draw():
    glClearColor(1.0, 1.0, 0.5, 0.0)
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
    glFlush()
    glutSwapBuffers()

def main():
    glutInit(sys.argv)
    glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH)
    glutInitWindowSize(300, 300)
    glutCreateWindow("PyOpenGL")
    glutDisplayFunc(draw)
    glutMainLoop()

main()
[Iwao@fedora pyopengl]$ python test.py 
Traceback (most recent call last):
  File "test.py", line 3, in 
    from OpenGL.GL import *
ImportError: No module named OpenGL.GL
[Iwao@fedora pyopengl]$ 

OpenGL 関係が足りないみたいで検索すると python-pyopengl が必要とある.
Pythonでグラフィックやるには?

[Iwao@fedora py_math]$ sudo dnf install python-pyopengl*
[sudo] Iwao のパスワード:
メタデータの期限切れの最終確認: 0:57:14 時間前の 2019年09月13日 16時39分16秒 に実施しました。
依存関係が解決しました。
================================================================================
 Package                Architecture Version                Repository     Size
================================================================================
インストール:
 python2-pyopengl       x86_64       3.1.1a1-15.fc30        fedora        2.4 M
依存関係のインストール:
 openblas-threads       x86_64       0.3.7-1.fc30           updates       4.8 M
 python2-numpy          x86_64       1:1.16.4-2.fc30        updates       3.9 M
 python2-nose           noarch       1.3.7-22.fc30          fedora        261 k

dnf install python-pyopengl
これで実行できるようになった.
PyOpenGL でのウィンドウの表示


2020/07/31
PyOpenGL 3.x The Python OpenGL Binding

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

コメントする

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です

%d人のブロガーが「いいね」をつけました。