SORACOM S+ Camera Basicの開発環境をUbuntuに構築
以下の公式ドキュメントの「PC の開発環境の構築」のセクションに手順が載っていますが、pip installに手こずったので、記録しておきます。
使用方法: アルゴリズムの更新方法 | SORACOM Mosaic | SORACOM Users
pyenvを入れて、venvでactivateするところまでは通常通りです。次は pip install です。
pip installすべきパッケージは以下に書いてあります。
リファレンス: SORACOM Mosaic Python module 一覧 | SORACOM Mosaic | SORACOM Users
この内容を requirements.txt
に入れて、以下を実行します。
$ pip install -r requirements.txt
エラーその1
pip installしたら、以下のようなエラーになりました。
ERROR: Could not find a version that satisfies the requirement tflite-runtime==2.1.0.post1 ERROR: No matching distribution found for tflite-runtime==2.1.0.post1
requirements.txt
の
tflite-runtime==2.1.0.post1
を
https://dl.google.com/coral/python/tflite_runtime-2.1.0.post1-cp37-cp37m-linux_x86_64.whl
に書き換えたら解決しました。
エラーその2
pip installしたら、以下のようなエラーになりました。
ERROR: Cannot install -r memo.txt (line 50) and tensorboard==2.0.2 because these package versions have conflicting dependencies. The conflict is caused by: The user requested tensorboard==2.0.2 tensorflow 1.14.0 depends on tensorboard<1.15.0 and >=1.14.0 To fix this you could try to: 1. loosen the range of package versions you've specified 2. remove package versions to allow pip attempt to solve the dependency conflict
requirements.txt
の
tensorboard==2.0.2
を
tensorboard==1.14.0
に書き換えたら解決しました。
エラーその3
pip installしたら、以下のようなエラーになりました。
CMake must be installed to build the following extensions: dlib
以下を実行したら解決しました。
$ sudo apt install -y cmake
エラーその4
pip installしたら、以下のようなエラーになりました。
build/temp.linux-x86_64-3.7/_webp.c:541:14: fatal error: webp/decode.h: No such file or directory 541 | #include <webp/decode.h> | ^~~~~~~~~~~~~~~ compilation terminated. error: command 'gcc' failed with exit status 1
以下を実行したら解決しました。
$ sudo apt install -y libwebp-dev
まとめ
以上でやっと pip install
成功しました。
SORACOMの公式ドキュメントと最終的な requirements.txt
の差分は以下の通りです。
@@ -46,11 +46,11 @@ scikit-learn==0.22.1 scipy==1.4.1 six==1.14.0 -tensorboard==2.0.2 +tensorboard==1.14.0 tensorflow==1.14.0 tensorflow-estimator==1.14.0 termcolor==1.1.0 -tflite-runtime==2.1.0.post1 +https://dl.google.com/coral/python/tflite_runtime-2.1.0.post1-cp37-cp37m-linux_x86_64.whl urllib3==1.25.8 webp==0.1.0a7 webptools==0.0.2
差分があってもいいのかは不明です。
バージョン情報
$ cat /etc/lsb-release DISTRIB_ID=Ubuntu DISTRIB_RELEASE=20.04 DISTRIB_CODENAME=focal DISTRIB_DESCRIPTION="Ubuntu 20.04.2 LTS"
PythonはSORACOMのドキュメントの通り、 3.7.3
です。