ホーム » Python (ページ 2)

Python」カテゴリーアーカイブ

2024年9月
1234567
891011121314
15161718192021
22232425262728
2930  

カテゴリー

アーカイブ

ブログ統計情報

  • 92,225 アクセス


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.

Python のインストール状態

PyOpenGL を使えるようにしたいと思い Python のインストール状態を調べてみた.
PyOpenGL は Python 2.7 が奨励となっている?


Ubuntu
Python のインストール状態 Ubuntu

iwao@VB-Ubuntu:~$ python

Command 'python' not found, but can be installed with:

sudo apt install python3         # version 3.7.3-1, or
sudo apt install python          # version 2.7.16-1
sudo apt install python-minimal  # version 2.7.16-1

You also have python3 installed, you can run 'python3' instead.

iwao@VB-Ubuntu:~$ python3
Python 3.7.3 (default, Aug 20 2019, 17:04:43) 
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 
iwao@VB-Ubuntu:~$ 

Fedora
Python のインストール状態 Fedora

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


[Iwao@fedora ~]$ python3
Python 3.7.4 (default, Jul  9 2019, 16:32:37) 
[GCC 9.1.1 20190503 (Red Hat 9.1.1-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 
[Iwao@fedora ~]$ 

Raspberry Pi
Python のインストール状態 Raspberry Pi

pi@raspberrypi:~ $ python
Python 2.7.13 (default, Sep 26 2018, 18:42:22) 
[GCC 6.3.0 20170516] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 
pi@raspberrypi:~ $ python3
Python 3.5.3 (default, Sep 27 2018, 17:25:39) 
[GCC 6.3.0 20170516] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 
pi@raspberrypi:~ $ 

Win10 (VS 2017 , VS 2019)
Python のインストール状態 Win10

Microsoft Windows [Version 10.0.18362.356]
(c) 2019 Microsoft Corporation. All rights reserved.

C:\Users\Iwao>py
Python 3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 22:22:05) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> ^Z


C:\Users\Iwao>where py
C:\Windows\py.exe

C:\Users\Iwao>

Python のインストール状態 .../VS/Shared/
VS 2013 以降の「新規プロジェクト」で「Python」がある.
VS 2013 新規プロジェクト Python

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

Anaconda3 が入っていた

以前購入した「Python で学び直す高校数学」.

読み進めていくと Anaconda が必要となっていて,そこで止まった状態に.


昨日 PC に入っている AP を見ていると Anaconda があった.
スタートメニュー Anaconda3
今回 PC 環境が新しくなって,開発環境なども VS 2005 ~ VS 2019 まで入れた.
その時インストールオプションをどの様に指定したか覚えてないが,VS 2017 のインストールで入った?


使い方があまりわかってないが,「Anaconda Prompt」を起動して python ~.py で動作するみたい.
Anaconda Prompt で  python ~.py

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

VirtualBox に Fedora

今度は Fedora
VirtualBox に Fedora
ダウンロードは次のところから可能.
https://getfedora.org/ja/workstation/


gcc なども含めて入っている.
Fedora zip unzip display コマンド


python3 も入っている.


2019/06/06 g++ は無かった.
Fedora で g++ を利用する

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

Pythonで学び直す高校数学

Pythonで学び直す高校数学を購入.


Python をどうやれば使えるのかわかってないが,試しに python と打ってみると何か起動するみたい.


Raspberry Pi

login as: pi
pi@192.168.1.34's password:
Linux raspberrypi 4.14.79-v7+ #1159 SMP Sun Nov 4 17:50:20 GMT 2018 armv7l

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Fri Apr  5 21:59:29 2019

SSH is enabled and the default password for the 'pi' user has not been changed.
This is a security risk - please login as the 'pi' user and type 'passwd' to set a new password.

pi@raspberrypi:~ $ python
Python 2.7.13 (default, Sep 26 2018, 18:42:22)
[GCC 6.3.0 20170516] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
pi@raspberrypi:~ $ python3
Python 3.5.3 (default, Sep 27 2018, 17:25:39)
[GCC 6.3.0 20170516] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>

Synology NAS

login as: Iwao
Iwao@DS115j's password:
Iwao@DS115j:~$ python
Python 2.7.12 (default, Sep  7 2018, 13:20:13)
[GCC 4.9.3 20150311 (prerelease)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> hex(120)
'0x78'
>>> bin(120)
'0b1111000'
>>>
Iwao@DS115j:~$ python3
-sh: python3: command not found
Iwao@DS115j:~$

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