設定の[Add/Remove Software]からアプリをインストールする GUIによるインストール
1.Python p5を使う仮想環境の作成
2. p5の環境を作動させる
3. Python外部ライブラリーを使う仮想環境にPython 5をインストールする
4.Python 5を使う
5. Raspberry pi 5でPython p5を実行した時のエラー
6. ウィンドウマネージャーの WaylandをX-11に切り替えるとp5はRaspberry Pi 4のときと同様に動作する
ohashi@raspberrypi:~ $ python -m venv ~/p5
topへohashi@raspberrypi:~ $ source ~/p5/bin/activate
(p5) ohashi@raspberrypi:~ $ pip list
Package Version
------------------ ---------
Package Version
---------- -------
pip 23.0.1
setuptools 66.1.1
(p5) ohashi@raspberrypi:~ $ deactivate
ohashi@raspberrypi:~ $ source ~/p5/bin/activate
(p5) ohashi@raspberrypi:~ $ sudo apt install libglfw3
(p5) ohashi@raspberrypi:~ $ pip install numpy
(p5) ohashi@raspberrypi:~ $ pip install vispy
(p5) ohashi@raspberrypi:~ $ pip list
Package Version
----------- -------
freetype-py 2.5.1
hsluv 5.0.4
kiwisolver 1.4.7
numpy 2.1.3
packaging 24.2
pip 23.0.1
setuptools 66.1.1
vispy 0.14.3
(p5) ohashi@raspberrypi:~ $ pip install p5 --no-dependencies
「--no-dependencies」を記載しないとエラーになる(p5はインストールされない)
(p5) ohashi@raspberrypi:~ $ pip install --upgrade urllib3
(p5) ohashi@raspberrypi:~ $ pip install --upgrade requests
from p5 import *
def setup():
size(200,200)
def draw():
background(255,255,0)
stroke(0)
stroke_weight(10)
line(0,0,width,height)
print("OK")
run()
GLFWError: (65544) b'Wayland: Focusing a window requires user interaction' warnings.warn(message, GLFWError)
この問題はGUTHUBなどで多数取り上げられているが、解決策は見つけられなかった。
参照 その他多数あり
Raspberry Pi 財団のフォーラム「Error when using p5 package in Python
Cannot install p5 package with Python 3.12 #469
当面の解決策
画面の大きさを横幅(width)、縦幅(height)を360ピクセルにする
def setup():
size(360,360)
ohashi@raspberrypi:~ $ sudo raspi-config
↓