文章目录
应用场景:问题1描述:原因分析:解决方案:先检查 ESP-IDF 工具链是否安装完整设定工具路径变量一切正常:
执行重新运行安装脚本后又报错:原因分析解决方法:第一步:安装python3.10-venv包(核心修复)第二步:重新执行 ESP-IDF 安装脚本,重建虚拟环境安装过程中会看到:
第三步:验证激活 ESP-IDF 环境
问题2描述:因为没有rich模块造成的激活失败:解决方法
应用场景:
ESP32-WSL开发环境搭建过程中遇到的问题及解决方案
问题1描述:
ESP-IDF wsl 开发环境搭建完毕后,执行激活命令失败。
comeon@CARtech-jg:~/esp-idf$ . ./export.sh
Checking "python3" ...
Python 3.10.12
"python3" has been detected
error: Unable to import the rich module: No module named 'rich'. Please execute the install script.
ERROR: Activation script failed
Command '['/home/comeon/.espressif/python_env/idf5.5_py3.10_env/bin/python', '/home/comeon/esp-idf/tools/export_utils/activate_venv.py', '--export', '--shell', 'bash']' returned non-zero exit status 1.
To view detailed debug information, set ESP_IDF_EXPORT_DEBUG=1 and run the export script again.
原因分析:
这个错误提示表明 ESP-IDF 环境激活失败,原因是缺少rich Python 模块。可以按照以下步骤解决:
首先确保你在 ESP-IDF 的 Python 虚拟环境中安装rich模块:
# 激活ESP-IDF的Python虚拟环境
source ~/.espressif/python_env/idf5.5_py3.10_env/bin/activate
# 安装rich模块
pip install rich
执行第一个命令时,报错:
comeon@CARtech-jg:~/esp-idf$ source ~/.espressif/python_env/idf5.5_py3.10_env/bin/activate
-bash: /home/comeon/.espressif/python_env/idf5.5_py3.10_env/bin/activate: No such file or directory
从错误信息来看,ESP-IDF 对应的 Python 虚拟环境目录 idf5.5_py3.10_env 不存在,可能是之前的 ESP-IDF 工具链安装不完整,或虚拟环境未成功创建导致的。
解决方案:
可按以下步骤重新修复环境,解决激活问题:
先检查 ESP-IDF 工具链是否安装完整
进入 esp-gitee-tools 目录(之前下载的工具目录,若忘记路径可通过 find ~ -name “esp-gitee-tools” 查找):
cd ~/esp-gitee-tools # 若路径不同,替换为实际的esp-gitee-tools目录
重新执行 ESP-IDF 的安装脚本,补全工具链和虚拟环境:
export EGT_PATH=$(pwd) # 设定工具路径变量
cd ~/esp-idf # 进入ESP-IDF主目录
$EGT_PATH/install.sh # 重新运行安装脚本
安装过程中会自动创建对应 Python 版本的虚拟环境(如 idf5.5_py3.10_env),并安装依赖模块。若出现 “是否继续” 的提示,输入 y 确认,等待安装完成(需保证网络稳定,避免中断)。
设定工具路径变量一切正常:
执行重新运行安装脚本后又报错:
comeon@CARtech-jg:~/esp-idf$ $EGT_PATH/install.sh
Detecting Python interpreter
Checking "python3" ...
Python 3.10.12
"python3" has been detected
Installing ESP-IDF tools
Updating /home/comeon/.espressif/idf-env.json
Selected targets are: esp32c3, esp32p4, esp32c2, esp32c6, esp32s2, esp32h2, esp32c61, esp32h21, esp32s3, esp32h4, esp32c5, esp32
Current system platform: linux-amd64
Installing tools: xtensa-esp-elf-gdb, riscv32-esp-elf-gdb, xtensa-esp-elf, riscv32-esp-elf, esp32ulp-elf, openocd-esp32, esp-rom-elfs
Skipping xtensa-esp-elf-gdb@16.2_20250324 (already installed)
Skipping riscv32-esp-elf-gdb@16.2_20250324 (already installed)
Skipping xtensa-esp-elf@esp-14.2.0_20241119 (already installed)
Skipping riscv32-esp-elf@esp-14.2.0_20241119 (already installed)
Skipping esp32ulp-elf@2.38_20240113 (already installed)
Skipping openocd-esp32@v0.12.0-esp32-20250226 (already installed)
Skipping esp-rom-elfs@20241011 (already installed)
Installing Python environment and packages
Python 3.10.12
/home/comeon/.espressif/python_env/idf5.5_py3.10_env/bin/python: No module named pip
WARNING: pip is not available in the existing virtual environment, new virtual environment will be created.
WARNING: Removing the existing Python environment in /home/comeon/.espressif/python_env/idf5.5_py3.10_env
Creating a new Python environment in /home/comeon/.espressif/python_env/idf5.5_py3.10_env
The virtual environment was not created successfully because ensurepip is not
available. On Debian/Ubuntu systems, you need to install the python3-venv
package using the following command.
apt install python3.10-venv
You may need to use sudo with that command. After installing the python3-venv
package, recreate your virtual environment.
Failing command: /home/comeon/.espressif/python_env/idf5.5_py3.10_env/bin/python3
Traceback (most recent call last):
File "/home/comeon/esp-idf/tools/idf_tools.py", line 3572, in <module>
main(sys.argv[1:])
File "/home/comeon/esp-idf/tools/idf_tools.py", line 3562, in main
action_func(args)
File "/home/comeon/esp-idf/tools/idf_tools.py", line 2830, in action_install_python_env
subprocess.check_call(
File "/usr/lib/python3.10/subprocess.py", line 369, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['/usr/bin/python3', '-m', 'venv', '/home/comeon/.espressif/python_env/idf5.5_py3.10_env']' returned non-zero exit status 1.
原因分析
从报错信息可以明确,问题根源是 Ubuntu 系统缺少python3.10-venv包—— 这是 Python 3.10 创建虚拟环境必需的组件,没有它会导致 ESP-IDF 无法生成idf5.5_py3.10_env虚拟环境,进而触发后续的pip缺失和激活失败。
解决方法:
第一步:安装python3.10-venv包(核心修复)
sudo apt update && sudo apt install -y python3.10-venv
udo apt update:更新软件源列表,确保能找到最新的python3.10-venv包;
sudo apt install -y python3.10-venv:自动确认安装(-y参数),避免手动输入y确认。
comeon@CARtech-jg:~/esp-idf$ sudo apt update && sudo apt install -y python3.10-venv
[sudo] password for comeon:
Get:1 http://security.ubuntu.com/ubuntu jammy-security InRelease [129 kB]
Hit:2 http://archive.ubuntu.com/ubuntu jammy InRelease
Get:3 http://archive.ubuntu.com/ubuntu jammy-updates InRelease [128 kB]
Get:4 http://archive.ubuntu.com/ubuntu jammy-backports InRelease [127 kB]
Get:5 http://security.ubuntu.com/ubuntu jammy-security/main amd64 Packages [2595 kB]
Get:6 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 Packages [2843 kB]
Get:7 http://archive.ubuntu.com/ubuntu jammy-updates/universe amd64 Packages [1227 kB]
Get:8 http://archive.ubuntu.com/ubuntu jammy-updates/universe Translation-en [304 kB]
Get:9 http://security.ubuntu.com/ubuntu jammy-security/universe amd64 Packages [994 kB]
Fetched 8347 kB in 8s (1060 kB/s)
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
222 packages can be upgraded. Run 'apt list --upgradable' to see them.
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
libpython3.10 libpython3.10-dev libpython3.10-minimal libpython3.10-stdlib python3-pip-whl python3-setuptools-whl
python3.10 python3.10-dev python3.10-minimal
Suggested packages:
python3.10-doc binfmt-support
The following NEW packages will be installed:
python3-pip-whl python3-setuptools-whl python3.10-venv
The following packages will be upgraded:
libpython3.10 libpython3.10-dev libpython3.10-minimal libpython3.10-stdlib python3.10 python3.10-dev
python3.10-minimal
7 upgraded, 3 newly installed, 0 to remove and 215 not upgraded.
Need to get 15.1 MB of archives.
After this operation, 2894 kB of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 python3.10-dev amd64 3.10.12-1~22.04.11 [508 kB]
Get:2 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 libpython3.10-dev amd64 3.10.12-1~22.04.11 [4764 kB]
Get:3 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 libpython3.10 amd64 3.10.12-1~22.04.11 [1949 kB]
Get:4 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 python3.10 amd64 3.10.12-1~22.04.11 [508 kB]
Get:5 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 libpython3.10-stdlib amd64 3.10.12-1~22.04.11 [1850 kB]
Get:6 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 python3.10-minimal amd64 3.10.12-1~22.04.11 [2264 kB]
Get:7 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 libpython3.10-minimal amd64 3.10.12-1~22.04.11 [815 kB]
Get:8 http://archive.ubuntu.com/ubuntu jammy-updates/universe amd64 python3-pip-whl all 22.0.2+dfsg-1ubuntu0.6 [1680 kB]
Get:9 http://archive.ubuntu.com/ubuntu jammy-updates/universe amd64 python3-setuptools-whl all 59.6.0-1.2ubuntu0.22.04.3 [789 kB]
Get:10 http://archive.ubuntu.com/ubuntu jammy-updates/universe amd64 python3.10-venv amd64 3.10.12-1~22.04.11 [5726 B]
Fetched 15.1 MB in 15s (1028 kB/s)
(Reading database ... 31282 files and directories currently installed.)
Preparing to unpack .../0-python3.10-dev_3.10.12-1~22.04.11_amd64.deb ...
Unpacking python3.10-dev (3.10.12-1~22.04.11) over (3.10.12-1~22.04.9) ...
Preparing to unpack .../1-libpython3.10-dev_3.10.12-1~22.04.11_amd64.deb ...
Unpacking libpython3.10-dev:amd64 (3.10.12-1~22.04.11) over (3.10.12-1~22.04.9) ...
Preparing to unpack .../2-libpython3.10_3.10.12-1~22.04.11_amd64.deb ...
Unpacking libpython3.10:amd64 (3.10.12-1~22.04.11) over (3.10.12-1~22.04.9) ...
Preparing to unpack .../3-python3.10_3.10.12-1~22.04.11_amd64.deb ...
Unpacking python3.10 (3.10.12-1~22.04.11) over (3.10.12-1~22.04.9) ...
Preparing to unpack .../4-libpython3.10-stdlib_3.10.12-1~22.04.11_amd64.deb ...
Unpacking libpython3.10-stdlib:amd64 (3.10.12-1~22.04.11) over (3.10.12-1~22.04.9) ...
Preparing to unpack .../5-python3.10-minimal_3.10.12-1~22.04.11_amd64.deb ...
Unpacking python3.10-minimal (3.10.12-1~22.04.11) over (3.10.12-1~22.04.9) ...
Preparing to unpack .../6-libpython3.10-minimal_3.10.12-1~22.04.11_amd64.deb ...
Unpacking libpython3.10-minimal:amd64 (3.10.12-1~22.04.11) over (3.10.12-1~22.04.9) ...
Selecting previously unselected package python3-pip-whl.
Preparing to unpack .../7-python3-pip-whl_22.0.2+dfsg-1ubuntu0.6_all.deb ...
Unpacking python3-pip-whl (22.0.2+dfsg-1ubuntu0.6) ...
Selecting previously unselected package python3-setuptools-whl.
Preparing to unpack .../8-python3-setuptools-whl_59.6.0-1.2ubuntu0.22.04.3_all.deb ...
Unpacking python3-setuptools-whl (59.6.0-1.2ubuntu0.22.04.3) ...
Selecting previously unselected package python3.10-venv.
Preparing to unpack .../9-python3.10-venv_3.10.12-1~22.04.11_amd64.deb ...
Unpacking python3.10-venv (3.10.12-1~22.04.11) ...
Setting up python3-setuptools-whl (59.6.0-1.2ubuntu0.22.04.3) ...
Setting up python3-pip-whl (22.0.2+dfsg-1ubuntu0.6) ...
Setting up libpython3.10-minimal:amd64 (3.10.12-1~22.04.11) ...
Setting up python3.10-minimal (3.10.12-1~22.04.11) ...
Setting up libpython3.10-stdlib:amd64 (3.10.12-1~22.04.11) ...
Setting up libpython3.10:amd64 (3.10.12-1~22.04.11) ...
Setting up python3.10 (3.10.12-1~22.04.11) ...
Setting up libpython3.10-dev:amd64 (3.10.12-1~22.04.11) ...
Setting up python3.10-dev (3.10.12-1~22.04.11) ...
Setting up python3.10-venv (3.10.12-1~22.04.11) ...
Processing triggers for man-db (2.10.2-1) ...
Processing triggers for libc-bin (2.35-0ubuntu3.1) ...
第二步:重新执行 ESP-IDF 安装脚本,重建虚拟环境
先进入esp-gitee-tools目录(确保EGT_PATH变量有效):
comeon@CARtech-jg:~/esp-idf$ cd ~/esp-gitee-tools # 若你的esp-gitee-tools在其他路径,替换为实际路径
export EGT_PATH=$(pwd) # 重新设定工具路径变量(避免变量失效)
comeon@CARtech-jg:~/esp-gitee-tools$
comeon@CARtech-jg:~/esp-gitee-tools$ cd ~/esp-idf
$EGT_PATH/install.sh
Detecting Python interpreter
Checking "python3" ...
Python 3.10.12
"python3" has been detected
Installing ESP-IDF tools
Updating /home/comeon/.espressif/idf-env.json
Selected targets are: esp32c2, esp32h4, esp32p4, esp32s3, esp32c61, esp32h21, esp32, esp32s2, esp32c6, esp32c5, esp32c3, esp32h2
Current system platform: linux-amd64
Installing tools: xtensa-esp-elf-gdb, riscv32-esp-elf-gdb, xtensa-esp-elf, riscv32-esp-elf, esp32ulp-elf, openocd-esp32, esp-rom-elfs
Skipping xtensa-esp-elf-gdb@16.2_20250324 (already installed)
Skipping riscv32-esp-elf-gdb@16.2_20250324 (already installed)
Skipping xtensa-esp-elf@esp-14.2.0_20241119 (already installed)
Skipping riscv32-esp-elf@esp-14.2.0_20241119 (already installed)
Skipping esp32ulp-elf@2.38_20240113 (already installed)
Skipping openocd-esp32@v0.12.0-esp32-20250226 (already installed)
Skipping esp-rom-elfs@20241011 (already installed)
Installing Python environment and packages
Python 3.10.12
/home/comeon/.espressif/python_env/idf5.5_py3.10_env/bin/python: No module named pip
WARNING: pip is not available in the existing virtual environment, new virtual environment will be created.
WARNING: Removing the existing Python environment in /home/comeon/.espressif/python_env/idf5.5_py3.10_env
Creating a new Python environment in /home/comeon/.espressif/python_env/idf5.5_py3.10_env
Downloading https://dl.espressif.com/dl/esp-idf/espidf.constraints.v5.5.txt
Destination: /home/comeon/.espressif/espidf.constraints.v5.5.txt.tmp
Done
Upgrading pip...
Requirement already satisfied: pip in /home/comeon/.espressif/python_env/idf5.5_py3.10_env/lib/python3.10/site-packages (22.0.2)
Collecting pip
Downloading pip-25.2-py3-none-any.whl (1.8 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.8/1.8 MB 20.7 kB/s eta 0:00:00
Installing collected packages: pip
Attempting uninstall: pip
Found existing installation: pip 22.0.2
Uninstalling pip-22.0.2:
Successfully uninstalled pip-22.0.2
Successfully installed pip-25.2
Upgrading setuptools...
Requirement already satisfied: setuptools in /home/comeon/.espressif/python_env/idf5.5_py3.10_env/lib/python3.10/site-packages (59.6.0)
Collecting setuptools
Downloading setuptools-71.0.0-py3-none-any.whl.metadata (6.5 kB)
Downloading setuptools-71.0.0-py3-none-any.whl (908 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 908.4/908.4 kB 24.8 kB/s 0:00:27
Installing collected packages: setuptools
Attempting uninstall: setuptools
Found existing installation: setuptools 59.6.0
Uninstalling setuptools-59.6.0:
Successfully uninstalled setuptools-59.6.0
Successfully installed setuptools-71.0.0
Installing Python packages
Constraint file: /home/comeon/.espressif/espidf.constraints.v5.5.txt
Requirement files:
- /home/comeon/esp-idf/tools/requirements/requirements.core.txt
Looking in indexes: https://pypi.org/simple, https://dl.espressif.com/pypi
Ignoring importlib_metadata: markers 'python_version < "3.8"' don't match your environment
Requirement already satisfied: setuptools in /home/comeon/.espressif/python_env/idf5.5_py3.10_env/lib/python3.10/site-packages (from -r /home/comeon/esp-idf/tools/requirements/requirements.core.txt (line 7)) (71.0.0)
Collecting packaging (from -r /home/comeon/esp-idf/tools/requirements/requirements.core.txt (line 8))
Downloading packaging-25.0-py3-none-any.whl.metadata (3.3 kB)
Collecting click (from -r /home/comeon/esp-idf/tools/requirements/requirements.core.txt (line 11))
Downloading https://dl.espressif.cn/pypi/click/click-8.1.8-py3-none-any.whl (98 kB)
Collecting pyserial (from -r /home/comeon/esp-idf/tools/requirements/requirements.core.txt (line 12))
Downloading https://dl.espressif.cn/pypi/pyserial/pyserial-3.5-py2.py3-none-any.whl (90 kB)
Collecting cryptography (from -r /home/comeon/esp-idf/tools/requirements/requirements.core.txt (line 13))
Downloading cryptography-44.0.3-cp39-abi3-manylinux_2_34_x86_64.whl.metadata (5.7 kB)
Collecting pyparsing (from -r /home/comeon/esp-idf/tools/requirements/requirements.core.txt (line 14))
Downloading pyparsing-3.2.3-py3-none-any.whl.metadata (5.0 kB)
Collecting pyelftools (from -r /home/comeon/esp-idf/tools/requirements/requirements.core.txt (line 15))
Downloading https://dl.espressif.cn/pypi/pyelftools/pyelftools-0.32-py3-none-any.whl (188 kB)
Collecting idf-component-manager (from -r /home/comeon/esp-idf/tools/requirements/requirements.core.txt (line 16))
Downloading idf_component_manager-2.3.0-py3-none-any.whl.metadata (9.4 kB)
Collecting esp-coredump (from -r /home/comeon/esp-idf/tools/requirements/requirements.core.txt (line 17))
Downloading esp_coredump-1.14.0-py3-none-any.whl.metadata (5.2 kB)
Collecting esptool (from -r /home/comeon/esp-idf/tools/requirements/requirements.core.txt (line 18))
Downloading esptool-4.10.dev2.tar.gz (461 kB)
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing metadata (pyproject.toml) ... done
Collecting esp-idf-kconfig (from -r /home/comeon/esp-idf/tools/requirements/requirements.core.txt (line 19))
Downloading https://dl.espressif.cn/pypi/esp-idf-kconfig/esp_idf_kconfig-2.5.0-py3-none-any.whl (143 kB)
Collecting esp-idf-monitor (from -r /home/comeon/esp-idf/tools/requirements/requirements.core.txt (line 20))
Downloading esp_idf_monitor-1.7.0-py3-none-any.whl.metadata (11 kB)
Collecting esp-idf-nvs-partition-gen (from -r /home/comeon/esp-idf/tools/requirements/requirements.core.txt (line 21))
Downloading esp_idf_nvs_partition_gen-0.1.9-py3-none-any.whl.metadata (14 kB)
Collecting esp-idf-size (from -r /home/comeon/esp-idf/tools/requirements/requirements.core.txt (line 22))
Downloading esp_idf_size-1.7.1-py3-none-any.whl.metadata (3.7 kB)
Collecting esp-idf-diag (from -r /home/comeon/esp-idf/tools/requirements/requirements.core.txt (line 23))
Downloading esp_idf_diag-0.2.0-py3-none-any.whl.metadata (3.6 kB)
Collecting esp-idf-panic-decoder (from -r /home/comeon/esp-idf/tools/requirements/requirements.core.txt (line 24))
Downloading esp_idf_panic_decoder-1.4.1-py3-none-any.whl.metadata (16 kB)
Collecting pyclang (from -r /home/comeon/esp-idf/tools/requirements/requirements.core.txt (line 25))
Downloading pyclang-0.6.3-py3-none-any.whl.metadata (2.7 kB)
Collecting construct (from -r /home/comeon/esp-idf/tools/requirements/requirements.core.txt (line 26))
Downloading https://dl.espressif.cn/pypi/construct/construct-2.10.70-py3-none-any.whl (63 kB)
Collecting rich (from -r /home/comeon/esp-idf/tools/requirements/requirements.core.txt (line 27))
Downloading rich-14.1.0-py3-none-any.whl.metadata (18 kB)
Collecting psutil (from -r /home/comeon/esp-idf/tools/requirements/requirements.core.txt (line 28))
Downloading https://dl.espressif.cn/pypi/psutil/psutil-7.0.0-cp36-abi3-manylinux_2_12_x86_64.manylinux2010_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (277 kB)
Collecting freertos_gdb (from -r /home/comeon/esp-idf/tools/requirements/requirements.core.txt (line 31))
Downloading https://dl.espressif.cn/pypi/freertos-gdb/freertos_gdb-1.0.4-py3-none-any.whl (14 kB)
Collecting cffi>=1.12 (from cryptography->-r /home/comeon/esp-idf/tools/requirements/requirements.core.txt (line 13))
Downloading https://dl.espressif.cn/pypi/cffi/cffi-1.17.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (446 kB)
Collecting colorama (from idf-component-manager->-r /home/comeon/esp-idf/tools/requirements/requirements.core.txt (line 16))
Downloading https://dl.espressif.cn/pypi/colorama/colorama-0.4.6-py2.py3-none-any.whl (25 kB)
Collecting ruamel.yaml (from idf-component-manager->-r /home/comeon/esp-idf/tools/requirements/requirements.core.txt (line 16))
Downloading ruamel.yaml-0.18.15-py3-none-any.whl.metadata (25 kB)
Collecting requests (from idf-component-manager->-r /home/comeon/esp-idf/tools/requirements/requirements.core.txt (line 16))
Downloading requests-2.32.5-py3-none-any.whl.metadata (4.9 kB)
Collecting requests-file (from idf-component-manager->-r /home/comeon/esp-idf/tools/requirements/requirements.core.txt (line 16))
Downloading https://dl.espressif.cn/pypi/requests-file/requests_file-2.1.0-py2.py3-none-any.whl (4.2 kB)
Collecting requests-toolbelt (from idf-component-manager->-r /home/comeon/esp-idf/tools/requirements/requirements.core.txt (line 16))
Downloading https://dl.espressif.cn/pypi/requests-toolbelt/requests_toolbelt-1.0.0-py2.py3-none-any.whl (54 kB)
Collecting tqdm (from idf-component-manager->-r /home/comeon/esp-idf/tools/requirements/requirements.core.txt (line 16))
Downloading https://dl.espressif.cn/pypi/tqdm/tqdm-4.67.1-py3-none-any.whl (78 kB)
Collecting jsonref (from idf-component-manager->-r /home/comeon/esp-idf/tools/requirements/requirements.core.txt (line 16))
Downloading https://dl.espressif.cn/pypi/jsonref/jsonref-1.1.0-py3-none-any.whl (9.4 kB)
Collecting pydantic (from idf-component-manager->-r /home/comeon/esp-idf/tools/requirements/requirements.core.txt (line 16))
Downloading pydantic-2.11.7-py3-none-any.whl.metadata (67 kB)
Collecting pydantic-core (from idf-component-manager->-r /home/comeon/esp-idf/tools/requirements/requirements.core.txt (line 16))
Downloading pydantic_core-2.39.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (7.3 kB)
Collecting pydantic-settings (from idf-component-manager->-r /home/comeon/esp-idf/tools/requirements/requirements.core.txt (line 16))
Downloading pydantic_settings-2.10.1-py3-none-any.whl.metadata (3.4 kB)
Collecting typing-extensions (from idf-component-manager->-r /home/comeon/esp-idf/tools/requirements/requirements.core.txt (line 16))
Downloading typing_extensions-4.15.0-py3-none-any.whl.metadata (3.3 kB)
Collecting truststore (from idf-component-manager->-r /home/comeon/esp-idf/tools/requirements/requirements.core.txt (line 16))
Downloading truststore-0.10.4-py3-none-any.whl.metadata (4.4 kB)
Collecting pygdbmi>=0.9.0.2 (from esp-coredump->-r /home/comeon/esp-idf/tools/requirements/requirements.core.txt (line 17))
Downloading https://dl.espressif.cn/pypi/pygdbmi/pygdbmi-0.11.0.0-py3-none-any.whl (21 kB)
Collecting bitstring!=4.2.0,>=3.1.6 (from esptool->-r /home/comeon/esp-idf/tools/requirements/requirements.core.txt (line 18))
Downloading https://dl.espressif.cn/pypi/bitstring/bitstring-4.3.1-py3-none-any.whl (71 kB)
Collecting ecdsa>=0.16.0 (from esptool->-r /home/comeon/esp-idf/tools/requirements/requirements.core.txt (line 18))
Downloading https://dl.espressif.cn/pypi/ecdsa/ecdsa-0.19.1-py2.py3-none-any.whl (150 kB)
Collecting reedsolo<1.8,>=1.5.3 (from esptool->-r /home/comeon/esp-idf/tools/requirements/requirements.core.txt (line 18))
Downloading https://dl.espressif.cn/pypi/reedsolo/reedsolo-1.7.0-py3-none-any.whl (32 kB)
Collecting PyYAML>=5.1 (from esptool->-r /home/comeon/esp-idf/tools/requirements/requirements.core.txt (line 18))
Downloading https://dl.espressif.cn/pypi/pyyaml/PyYAML-6.0.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (751 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 751.2/751.2 kB 3.2 MB/s 0:00:00
Collecting intelhex (from esptool->-r /home/comeon/esp-idf/tools/requirements/requirements.core.txt (line 18))
Downloading https://dl.espressif.cn/pypi/intelhex/intelhex-2.3.0-py2.py3-none-any.whl (50 kB)
Collecting argcomplete>=3 (from esptool->-r /home/comeon/esp-idf/tools/requirements/requirements.core.txt (line 18))
Downloading https://dl.espressif.cn/pypi/argcomplete/argcomplete-3.6.2-py3-none-any.whl (43 kB)
Collecting markdown-it-py>=2.2.0 (from rich->-r /home/comeon/esp-idf/tools/requirements/requirements.core.txt (line 27))
Downloading markdown_it_py-4.0.0-py3-none-any.whl.metadata (7.3 kB)
Collecting pygments<3.0.0,>=2.13.0 (from rich->-r /home/comeon/esp-idf/tools/requirements/requirements.core.txt (line 27))
Downloading pygments-2.19.2-py3-none-any.whl.metadata (2.5 kB)
Collecting bitarray<4.0,>=3.0.0 (from bitstring!=4.2.0,>=3.1.6->esptool->-r /home/comeon/esp-idf/tools/requirements/requirements.core.txt (line 18))
Downloading bitarray-3.7.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (35 kB)
Collecting pycparser (from cffi>=1.12->cryptography->-r /home/comeon/esp-idf/tools/requirements/requirements.core.txt (line 13))
Downloading https://dl.espressif.cn/pypi/pycparser/pycparser-2.22-py3-none-any.whl (117 kB)
Collecting six>=1.9.0 (from ecdsa>=0.16.0->esptool->-r /home/comeon/esp-idf/tools/requirements/requirements.core.txt (line 18))
Downloading https://dl.espressif.cn/pypi/six/six-1.17.0-py2.py3-none-any.whl (11 kB)
Collecting mdurl~=0.1 (from markdown-it-py>=2.2.0->rich->-r /home/comeon/esp-idf/tools/requirements/requirements.core.txt (line 27))
Downloading https://dl.espressif.cn/pypi/mdurl/mdurl-0.1.2-py3-none-any.whl (10.0 kB)
Collecting annotated-types>=0.6.0 (from pydantic->idf-component-manager->-r /home/comeon/esp-idf/tools/requirements/requirements.core.txt (line 16))
Downloading https://dl.espressif.cn/pypi/annotated-types/annotated_types-0.7.0-py3-none-any.whl (13 kB)
Collecting pydantic-core (from idf-component-manager->-r /home/comeon/esp-idf/tools/requirements/requirements.core.txt (line 16))
Downloading pydantic_core-2.33.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (6.8 kB)
Collecting typing-inspection>=0.4.0 (from pydantic->idf-component-manager->-r /home/comeon/esp-idf/tools/requirements/requirements.core.txt (line 16))
Downloading typing_inspection-0.4.1-py3-none-any.whl.metadata (2.6 kB)
Collecting python-dotenv>=0.21.0 (from pydantic-settings->idf-component-manager->-r /home/comeon/esp-idf/tools/requirements/requirements.core.txt (line 16))
Downloading python_dotenv-1.1.1-py3-none-any.whl.metadata (24 kB)
Collecting charset_normalizer<4,>=2 (from requests->idf-component-manager->-r /home/comeon/esp-idf/tools/requirements/requirements.core.txt (line 16))
Downloading charset_normalizer-3.4.3-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.metadata (36 kB)
Collecting idna<4,>=2.5 (from requests->idf-component-manager->-r /home/comeon/esp-idf/tools/requirements/requirements.core.txt (line 16))
Downloading https://dl.espressif.cn/pypi/idna/idna-3.10-py3-none-any.whl (70 kB)
Collecting urllib3<3,>=1.21.1 (from requests->idf-component-manager->-r /home/comeon/esp-idf/tools/requirements/requirements.core.txt (line 16))
Downloading https://dl.espressif.cn/pypi/urllib3/urllib3-1.26.20-py2.py3-none-any.whl (144 kB)
Collecting certifi>=2017.4.17 (from requests->idf-component-manager->-r /home/comeon/esp-idf/tools/requirements/requirements.core.txt (line 16))
Downloading certifi-2025.8.3-py3-none-any.whl.metadata (2.4 kB)
Collecting ruamel.yaml.clib>=0.2.7 (from ruamel.yaml->idf-component-manager->-r /home/comeon/esp-idf/tools/requirements/requirements.core.txt (line 16))
Downloading ruamel.yaml.clib-0.2.12-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (2.7 kB)
Downloading packaging-25.0-py3-none-any.whl (66 kB)
Downloading cryptography-44.0.3-cp39-abi3-manylinux_2_34_x86_64.whl (4.2 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 4.2/4.2 MB 16.3 kB/s 0:03:52
Downloading pyparsing-3.2.3-py3-none-any.whl (111 kB)
Downloading idf_component_manager-2.3.0-py3-none-any.whl (170 kB)
Downloading esp_coredump-1.14.0-py3-none-any.whl (42 kB)
Downloading esp_idf_monitor-1.7.0-py3-none-any.whl (54 kB)
Downloading esp_idf_panic_decoder-1.4.1-py3-none-any.whl (21 kB)
Downloading esp_idf_nvs_partition_gen-0.1.9-py3-none-any.whl (22 kB)
Downloading esp_idf_size-1.7.1-py3-none-any.whl (82 kB)
Downloading esp_idf_diag-0.2.0-py3-none-any.whl (23 kB)
Downloading pyclang-0.6.3-py3-none-any.whl (12 kB)
Downloading rich-14.1.0-py3-none-any.whl (243 kB)
Downloading pygments-2.19.2-py3-none-any.whl (1.2 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.2/1.2 MB 17.5 kB/s 0:00:51
Downloading bitarray-3.7.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (322 kB)
Downloading markdown_it_py-4.0.0-py3-none-any.whl (87 kB)
Downloading pydantic-2.11.7-py3-none-any.whl (444 kB)
Downloading pydantic_core-2.33.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.0 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2.0/2.0 MB 24.7 kB/s 0:01:37
Downloading typing_extensions-4.15.0-py3-none-any.whl (44 kB)
Downloading typing_inspection-0.4.1-py3-none-any.whl (14 kB)
Downloading pydantic_settings-2.10.1-py3-none-any.whl (45 kB)
Downloading python_dotenv-1.1.1-py3-none-any.whl (20 kB)
Downloading requests-2.32.5-py3-none-any.whl (64 kB)
Downloading charset_normalizer-3.4.3-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (152 kB)
Downloading certifi-2025.8.3-py3-none-any.whl (161 kB)
Downloading ruamel.yaml-0.18.15-py3-none-any.whl (119 kB)
Downloading ruamel.yaml.clib-0.2.12-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (722 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 722.2/722.2 kB 17.6 kB/s 0:00:40
Downloading truststore-0.10.4-py3-none-any.whl (18 kB)
Building wheels for collected packages: esptool
Building wheel for esptool (pyproject.toml) ... done
Created wheel for esptool: filename=esptool-4.10.dev2-py3-none-any.whl size=583712 sha256=55258c4c655df123cfc111c42bcf78d726891f85dcebbba7e4ab106721e05e0d
Stored in directory: /home/comeon/.cache/pip/wheels/2c/07/5a/84bf60fc53179cc6734367dd31e84f5ce7c08dcd457117ed21
Successfully built esptool
Installing collected packages: reedsolo, pyserial, pygdbmi, pyelftools, intelhex, bitarray, urllib3, typing-extensions, truststore, tqdm, six, ruamel.yaml.clib, PyYAML, python-dotenv, pyparsing, pygments, pycparser, pyclang, psutil, packaging, mdurl, jsonref, idna, freertos_gdb, esp-idf-panic-decoder, esp-idf-kconfig, construct, colorama, click, charset_normalizer, certifi, bitstring, argcomplete, annotated-types, typing-inspection, ruamel.yaml, requests, pydantic-core, markdown-it-py, ecdsa, cffi, rich, requests-toolbelt, requests-file, pydantic, cryptography, pydantic-settings, esptool, esp-idf-size, esp-idf-nvs-partition-gen, esp-idf-diag, idf-component-manager, esp-coredump, esp-idf-monitor
Successfully installed PyYAML-6.0.2 annotated-types-0.7.0 argcomplete-3.6.2 bitarray-3.7.0 bitstring-4.3.1 certifi-2025.8.3 cffi-1.17.1 charset_normalizer-3.4.3 click-8.1.8 colorama-0.4.6 construct-2.10.70 cryptography-44.0.3 ecdsa-0.19.1 esp-coredump-1.14.0 esp-idf-diag-0.2.0 esp-idf-kconfig-2.5.0 esp-idf-monitor-1.7.0 esp-idf-nvs-partition-gen-0.1.9 esp-idf-panic-decoder-1.4.1 esp-idf-size-1.7.1 esptool-4.10.dev2 freertos_gdb-1.0.4 idf-component-manager-2.3.0 idna-3.10 intelhex-2.3.0 jsonref-1.1.0 markdown-it-py-4.0.0 mdurl-0.1.2 packaging-25.0 psutil-7.0.0 pyclang-0.6.3 pycparser-2.22 pydantic-2.11.7 pydantic-core-2.33.2 pydantic-settings-2.10.1 pyelftools-0.32 pygdbmi-0.11.0.0 pygments-2.19.2 pyparsing-3.2.3 pyserial-3.5 python-dotenv-1.1.1 reedsolo-1.7.0 requests-2.32.5 requests-file-2.1.0 requests-toolbelt-1.0.0 rich-14.1.0 ruamel.yaml-0.18.15 ruamel.yaml.clib-0.2.12 six-1.17.0 tqdm-4.67.1 truststore-0.10.4 typing-extensions-4.15.0 typing-inspection-0.4.1 urllib3-1.26.20
All done! You can now run:
. /home/comeon/esp-idf/export.sh
comeon@CARtech-jg:~/esp-idf$
安装过程中会看到:
不再提示 “ensurepip is not available” 错误;
会自动创建/home/comeon/.espressif/python_env/idf5.5_py3.10_env虚拟环境;
并自动安装pip及 ESP-IDF 所需的 Python 依赖(包括rich模块)。
第三步:验证激活 ESP-IDF 环境
cd ~/esp-idf
. ./export.sh
安装后再次激活,这次成功了!!!
comeon@CARtech-jg:~/esp-idf$ cd ~/esp-idf
. ./export.sh
Checking "python3" ...
Python 3.10.12
"python3" has been detected
Activating ESP-IDF 5.5
Setting IDF_PATH to '/home/comeon/esp-idf'.
* Checking python version ... 3.10.12
* Checking python dependencies ... OK
* Deactivating the current ESP-IDF environment (if any) ... OK
* Establishing a new ESP-IDF environment ... OK
* Identifying shell ... bash
* Detecting outdated tools in system ... OK - no outdated tools found
* Shell completion ... Autocompletion code generated
Done! You can now compile ESP-IDF projects.
Go to the project directory and run:
idf.py build
comeon@CARtech-jg:~/esp-idf$
问题2描述:
因为没有rich模块造成的激活失败:
comeon@CARtech-jg:~/esp-idf$ . ./export.sh
Checking "python3" ...
Python 3.10.12
"python3" has been detected
error: Unable to import the rich module: No module named 'rich'. Please execute the install script.
ERROR: Activation script failed
Command '['/home/comeon/.espressif/python_env/idf5.5_py3.10_env/bin/python', '/home/comeon/esp-idf/tools/export_utils/activate_venv.py', '--export', '--shell', 'bash']' returned non-zero exit status 1.
To view detailed debug information, set ESP_IDF_EXPORT_DEBUG=1 and run the export script again.
解决方法
安装rich模块:
pip3 install rich
comeon@CARtech-jg:~/esp-idf$ pip3 install rich
Defaulting to user installation because normal site-packages is not writeable
Collecting rich
Downloading rich-14.1.0-py3-none-any.whl (243 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 243.4/243.4 KB 23.1 kB/s eta 0:00:00
Collecting markdown-it-py>=2.2.0
Downloading markdown_it_py-4.0.0-py3-none-any.whl (87 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 87.3/87.3 KB 17.1 kB/s eta 0:00:00
Collecting pygments<3.0.0,>=2.13.0
Downloading pygments-2.19.2-py3-none-any.whl (1.2 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.2/1.2 MB 16.3 kB/s eta 0:00:00
Collecting mdurl~=0.1
Downloading mdurl-0.1.2-py3-none-any.whl (10.0 kB)
Installing collected packages: pygments, mdurl, markdown-it-py, rich
WARNING: The script pygmentize is installed in '/home/comeon/.local/bin' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
WARNING: The script markdown-it is installed in '/home/comeon/.local/bin' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed markdown-it-py-4.0.0 mdurl-0.1.2 pygments-2.19.2 rich-14.1.0