08. bookworm導入とpython bokeh対応

bookworm番OSがリリースされたので32ビット版を導入したが、pythonパッケージのbokehがinstallできず対応した。
また、RealVNCが利用できなかった(64bit版OSではOKだった)が対処方法が見つかり対応した。

●現象
pythonでグラフ作成に使用していたパッケージbokehがインストールできない

$ sudo pip3 install bokeh error: externally-managed-environment × This environment is externally managed ╰─> To install Python packages system-wide, try apt install python3-xyz, where xyz is the package you are trying to install. If you wish to install a non-Debian-packaged Python package, create a virtual environment using python3 -m venv path/to/venv. Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make sure you have python3-full installed. For more information visit http://rptl.io/venv note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages. hint: See PEP 668 for the detailed specification. ※aptでインストールを試みたが駄目だった $ sudo apt install python3-bokeh パッケージリストを読み込んでいます... 完了 依存関係ツリーを作成しています... 完了 状態情報を読み取っています... 完了 パッケージ python3-bokeh は使用できませんが、別のパッケージから参照されます。 これは、パッケージが欠落しているか、廃止されたか、または別のソース からのみ利用可能であることを意味します。 E: パッケージ 'python3-bokeh' にはインストール候補がありません

●対応
bokehはpythonの仮想環境(venv)の中で導入出来ることが分り、それに合わせて自作prgも一部修正した。

01. 仮想環境(venv)を導入しbokehのインストール $ python -m venv --system-site-packages ~/.env $ source ~/.env/bin/activate ← 仮想環境に入る (env) $ pip install bokeh : (env) $ deactivate ← 元に戻す(仮想環境を出る) $ rm -rf ~/.env ← venv環境を削除する場合 02. 最新版bokehの仕様が一部変更になっていたので自作prgを修正 ・plot_width と plot_height を単に width と height と変更する ・legend を legend_label に変更する 03. 自作prg起動用のシェルを作成 #! /bin/bash # Activating virtualenv source /home/pi/.env/bin/activate #echo $VIRTUAL_ENV ← 環境が変更されたか確認する場合 cd /home/pi/pywork/tager/comfort3/exe python sql-graph_average.py # deactivating VirtualEnv deactivate

●vncのこと
64bit版bookwormでは問題なかったが、32bit版bookwormではRealVNCがアクセスできずネットを調べた結果以下の方法で対応できた。

$ mkdir ~/delete_after_move $ cd ~/delete_after_move $ wget -nv https://github.com/raspberrypi/firmware/raw/master/opt/vc/lib/libbcm_host.so $ wget -nv https://github.com/raspberrypi/firmware/raw/master/opt/vc/lib/libvcos.so $ wget -nv https://github.com/raspberrypi/firmware/raw/master/opt/vc/lib/libmmal.so $ wget -nv https://github.com/raspberrypi/firmware/raw/master/opt/vc/lib/libmmal_core.so $ wget -nv https://github.com/raspberrypi/firmware/raw/master/opt/vc/lib/libmmal_components.so $ wget -nv https://github.com/raspberrypi/firmware/raw/master/opt/vc/lib/libmmal_util.so $ wget -nv https://github.com/raspberrypi/firmware/raw/master/opt/vc/lib/libmmal_vc_client.so $ wget -nv https://github.com/raspberrypi/firmware/raw/master/opt/vc/lib/libvchiq_arm.so $ wget -nv https://github.com/raspberrypi/firmware/raw/master/opt/vc/lib/libvcsm.so $ wget -nv https://github.com/raspberrypi/firmware/raw/master/opt/vc/lib/libcontainers.so $ sudo mv ~/delete_after_move/*.so /usr/lib/ $ cd .. $ rmdir ~/delete_after_move $ sudo systemctl restart vncserver-x11-serviced.service

【参考】

  1. RealVNC on 32-bit RasPiOS issue #41
  2. Using pip with virtual environments
  3. venv で Python の分離環境をつくる

このページは"Vue.js"を利用してみました。
2024/03/06