はじめに
AtomVM 開発などで ESP32 を扱う時に esptool がよく登場します。
公式の導入手順では Python の仮想環境を使うやり方とか色々でてきて、Python に慣れていない私にはややこしく見えます。
普段 mise をいろんなツールの管理に使っています。 mise にはいろんなバックエンドと連携してツールをインストールする機能がありますときいてはいましたが、まだ試していませんでした。
そこで、今回は pipx 連携で esptool をインストールすることに挑戦してみることにしました。
※ 写真はイメージです
対象環境
-
miseはすでに導入済み -
pipxはすでに導入済み -
pythonはすでに導入済み
mise --version
pipx --version
python --version
pipx は各 OS のシステムパッケージでインストールできるようです。手元のマシンでは、Debian系なので、sudo apt install pipx でインストールしました。
公式ドキュメントによると、esptool の最新版には Python 3.10以上と書いてあるので、古い Python を使っている場合は esptool のバージョンを固定するなどの工夫が必要になるかもしれません。
You will need Python 3.10 or newer installed on your system to use the latest version of esptool. If your use case requires Python 3.7, 3.8, or 3.9, please use esptool v4.x. For Python 2.7, 3.4, 3.5, or 3.6, please use esptool v3.3.* instead.
インストール
mise use --global pipx:esptool
たとえば Python 3.9 を使っていて、esptool v4 を指定したいときはこんな感じでできます。
mise use --global pipx:esptool@4
アンインストール
インストール済みの実体を削除するだけの場合
mise uninstall pipx:esptool
設定ファイルからも消したい場合
mise unuse pipx:esptool
idf.py が動かなくなったときの対処
今回の esptool のインストールし直しが直接影響したのかどうかわかりませんが、しばらくしてから ESP-IDF のコマンドを実行したら、エラーが出て戸惑いました。
ついでに Python のバージョンを最新版にしたからかもしれません。Python はちょっと前のバージョンにロックしておいたほうがトラブルが少ないのかもしれません。しらんけど。
$ source ~/esp/esp-idf/export.fish
Checking "python3" ...
Python 3.14.2
python3 has been detected
Activating ESP-IDF 5.4
* Checking python version ... 3.14.2
* Checking python dependencies ... FAILED
error: Command "/home/mnishiguchi/.espressif/python_env/idf5.4_py3.14_env/bin/python /home/mnishiguchi/esp/esp-idf/tools/idf_tools.py check-python-dependencies" failed with error code 255
The following Python requirements are not satisfied:
Error while checking requirement 'esptool~=4.8'. Package was not found and is required by the application: No package metadata was found for esptool
Error while checking requirement 'psutil'. Package was not found and is required by the application: No package metadata was found for esptool
Error while checking requirement 'psutil'. Package was not found and is required by the application: No package metadata was found for esptool
To install the missing packages, please run "install.sh"
Diagnostic information:
IDF_PYTHON_ENV_PATH: /home/mnishiguchi/.espressif/python_env/idf5.4_py3.14_env
Python interpreter used: /home/mnishiguchi/.espressif/python_env/idf5.4_py3.14_env/bin/python
Constraint file: /home/mnishiguchi/.espressif/espidf.constraints.v5.4.txt
Requirement files:
- /home/mnishiguchi/esp/esp-idf/tools/requirements/requirements.core.txt
Python being checked: /home/mnishiguchi/.espressif/python_env/idf5.4_py3.14_env/bin/python
ERROR: Activation script failed
To view detailed debug information, set ESP_IDF_EXPORT_DEBUG=1 and run the export script again.
最終的に、以下のように ESP-IDF をインストールし直したら、解消できました。
rm -rf ~/.espressif/python_env/*
~/esp/esp-idf/install.fish
source ~/esp/esp-idf/export.fish
おわりに
公式手順にはいろんなやりかたが細かく書かれていますが、mise の pipx 連携を利用するとあっさり簡単にできてしまいました。
自分の環境では esptool はいつでも使える便利な道具なので、こういうかんたんな入れ方が一番うれしいです。
![]()
![]()
![]()
