Raspberry pi OS Raspbian GNU/Linux 13 (trixie) コマンド備忘録 4 python仮想環境 mh-z19
mkdir python
uv init mh-z19-test
で ~/python/mh-z19を作成。
cd mh-z19-test
uv add mh-z19
するがエラーになるので事前に、以下の2つをインストールしてから実行
sudo apt install -y swig
sudo apt install -y liblgpio-dev
uv add mh-z19
uv add mh-z19 を普通にすると以下のエラーが出る。
Built mh-z19==3.1.7
Built getrpimodel==0.1.26
× Failed to build `lgpio==0.2.2.0`
├─▶ The build backend returned an error
╰─▶ Call to `setuptools.build_meta:__legacy__.build_wheel` failed (exit status: 1)
[stdout]
running bdist_wheel
running build
running build_py
running build_ext
building '_lgpio' extension
swigging lgpio.i to lgpio_wrap.c
swig -python -o lgpio_wrap.c lgpio.i
[stderr]
error: command 'swig' failed: No such file or directory
hint: This usually indicates a problem with the package or the build environment.
help: If you want to add the package regardless of the failed resolution, provide the `--frozen` flag to skip locking and syncing.
ってエラー。
sudo apt install -y swig
でswigをインストール。再度 uv add mh-z19が再度エラー
× Failed to build `lgpio==0.2.2.0`
├─▶ The build backend returned an error
╰─▶ Call to `setuptools.build_meta:__legacy__.build_wheel` failed (exit status: 1)
[stdout]
running bdist_wheel
running build
running build_py
running build_ext
building '_lgpio' extension
swigging lgpio.i to lgpio_wrap.c
swig -python -o lgpio_wrap.c lgpio.i
creating build/temp.linux-armv6l-cpython-313
arm-linux-gnueabihf-gcc -fno-strict-overflow -Wsign-compare -DNDEBUG -g -O2 -Wall -fPIC -Isrc
-I/home/localadmin/.cache/uv/builds-v0/.tmpUZ3upG/include -I/usr/include/python3.13 -c lgpio_wrap.c -o
build/temp.linux-armv6l-cpython-313/lgpio_wrap.o
creating build/lib.linux-armv6l-cpython-313
arm-linux-gnueabihf-gcc -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-z,relro -g -fwrapv -O2 build/temp.linux-armv6l-cpython-313/lgpio_wrap.o
-L/usr/lib/arm-linux-gnueabihf -llgpio -o build/lib.linux-armv6l-cpython-313/_lgpio.cpython-313-arm-linux-gnueabihf.so
[stderr]
/usr/bin/ld: cannot find -llgpio: No such file or directory
collect2: error: ld returned 1 exit status
error: command '/usr/bin/arm-linux-gnueabihf-gcc' failed with exit code 1
hint: This error likely indicates that you need to install the library that provides a shared library for `lgpio` for `lgpio@0.2.2.0`
(e.g., `liblgpio-dev`)
help: If you want to add the package regardless of the failed resolution, provide the `--frozen` flag to skip locking and syncing.
lgpioがないと言うエラーなので
sudo apt install -y liblgpio-dev 再度 uv add mh-z19
取りあえずエラー無しでインストールできた。
が使えない
mh-z19 3.1.7がインストールされている
------------------
~/python/mh-z19に移動して仮想環境に入る
source .venv/bin/activate
sudo chmod a+rw /dev/ttyS0
python3 -m mh_z19 --serial_console_untouched
で値がとれるのだが、何回か実行すると読めなくなる。
ここからは別方法
sudo pip install mh-z19 --break-system-packages
でインストール
sudo python3 -m mh_z19
{}
値が取得できない。。。。。以下でアンインストール
sudo pip uninstall mh-z19 --break-system-packages
コメント
コメントを投稿