乐鑫技术交流
直播中

杨福林

7年用户 1512经验值
私信 关注
[问答]

将版本从v3.3更新至v4.2版本后,idf.py无法使用怎么解决?

看了官方的说明文档,v4.2采用Python3,所以将Python改为了python3.6,从github上下载了zip包,解压到~/esp目录下,分别完成了install.sh和export.sh结果都成功,分别如下:
Code: Select all
eric@eric-virtual-machine:~/esp/esp-idf$ sudo ./install.sh[sudo] password for eric: Detecting the Python interpreterChecking "python" ...Python 3.6.9"python" has been detectedInstalling ESP-IDF toolsInstalling tools: xtensa-esp32-elf, xtensa-esp32s2-elf, esp32ulp-elf, esp32s2ulp-elf, openocd-esp32Skipping xtensa-esp32-elf@esp-2020r3-8.4.0 (already installed)Skipping xtensa-esp32s2-elf@esp-2020r3-8.4.0 (already installed)Skipping esp32ulp-elf@2.28.51-esp-20191205 (already installed)Skipping esp32s2ulp-elf@2.28.51-esp-20191205 (already installed)Skipping openocd-esp32@v0.10.0-esp32-20200709 (already installed)Installing Python environment and packagesfatal: not a git repository (or any of the parent directories): .gitWARNING: Git describe was unsuccessul: Command '['git', 'describe']' returned non-zero exit status 128.Installing Python packages from /home/eric/esp/esp-idf/requirements.txtWARNING: The directory '/home/eric/.cache/pip' or its parent directory is not owned or is not writable by the current user. The cache has been disabled. Check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.Ignoring python-socketio: markers 'python_version <= "2.7"' don't match your environmentIgnoring None: markers 'sys_platform == "win32"' don't match your environmentRequirement already satisfied: setuptools>=21 in /home/eric/.espressif/python_env/idf4.2_py3.6_env/lib/python3.6/site-packages (from -r /home/eric/esp/esp-idf/requirements.txt (line 4)) (54.1.2)Requirement already satisfied: click>=5.0 in /home/eric/.espressif/python_env/idf4.2_py3.6_env/lib/python3.6/site-packages (from -r /home/eric/esp/esp-idf/requirements.txt (line 8)) (7.1.2)Requirement already satisfied: pyserial>=3.0 in /home/eric/.espressif/python_env/idf4.2_py3.6_env/lib/python3.6/site-packages (from -r /home/eric/esp/esp-idf/requirements.txt (line 9)) (3.5)Requirement already satisfied: future>=0.15.2 in /home/eric/.espressif/python_env/idf4.2_py3.6_env/lib/python3.6/site-packages (from -r /home/eric/esp/esp-idf/requirements.txt (line 10)) (0.18.2)Requirement already satisfied: cryptography>=2.1.4 in /home/eric/.espressif/python_env/idf4.2_py3.6_env/lib/python3.6/site-packages (from -r /home/eric/esp/esp-idf/requirements.txt (line 11)) (3.4.7)Requirement already satisfied: pyparsing<2.4.0,>=2.0.3 in /home/eric/.espressif/python_env/idf4.2_py3.6_env/lib/python3.6/site-packages (from -r /home/eric/esp/esp-idf/requirements.txt (line 12)) (2.3.1)Requirement already satisfied: pyelftools>=0.22 in /home/eric/.espressif/python_env/idf4.2_py3.6_env/lib/python3.6/site-packages (from -r /home/eric/esp/esp-idf/requirements.txt (line 13)) (0.27)Requirement already satisfied: gdbgui==0.13.2.0 in /home/eric/.espressif/python_env/idf4.2_py3.6_env/lib/python3.6/site-packages (from -r /home/eric/esp/esp-idf/requirements.txt (line 15)) (0.13.2.0)Requirement already satisfied: pygdbmi<=0.9.0.2 in /home/eric/.espressif/python_env/idf4.2_py3.6_env/lib/python3.6/site-packages (from -r /home/eric/esp/esp-idf/requirements.txt (line 18)) (0.9.0.2)Requirement already satisfied: reedsolo<=1.5.4,>=1.5.3 in /home/eric/.espressif/python_env/idf4.2_py3.6_env/lib/python3.6/site-packages (from -r /home/eric/esp/esp-idf/requirements.txt (line 23)) (1.5.4)Requirement already satisfied: bitstring>=3.1.6 in /home/eric/.espressif/python_env/idf4.2_py3.6_env/lib/python3.6/site-packages (from -r /home/eric/esp/esp-idf/requirements.txt (line 24)) (3.1.7)Requirement already satisfied: ecdsa>=0.16.0 in /home/eric/.espressif/python_env/idf4.2_py3.6_env/lib/python3.6/site-packages (from -r /home/eric/esp/esp-idf/requirements.txt (line 25)) (0.16.1)Requirement already satisfied: gevent<2.0,>=1.2.2 in /home/eric/.espressif/python_env/idf4.2_py3.6_env/lib/python3.6/site-packages (from gdbgui==0.13.2.0->-r /home/eric/esp/esp-idf/requirements.txt (line 15)) (1.5.0)Requirement already satisfied: Flask-SocketIO<3.0,>=2.9 in /home/eric/.espressif/python_env/idf4.2_py3.6_env/lib/python3.6/site-packages (from gdbgui==0.13.2.0->-r /home/eric/esp/esp-idf/requirements.txt (line 15)) (2.9.6)Requirement already satisfied: Flask<1.0,>=0.12.2 in /home/eric/.espressif/python_env/idf4.2_py3.6_env/lib/python3.6/site-packages (from gdbgui==0.13.2.0->-r /home/eric/esp/esp-idf/requirements.txt (line 15)) (0.12.5)Requirement already satisfied: Flask-Compress<2.0,>=1.4.0 in /home/eric/.espressif/python_env/idf4.2_py3.6_env/lib/python3.6/site-packages (from gdbgui==0.13.2.0->-r /home/eric/esp/esp-idf/requirements.txt (line 15)) (1.9.0)Requirement already satisfied: Pygments<3.0,>=2.2.0 in /home/eric/.espressif/python_env/idf4.2_py3.6_env/lib/python3.6/site-packages (from gdbgui==0.13.2.0->-r /home/eric/esp/esp-idf/requirements.txt (line 15)) (2.8.1)Requirement already satisfied: cffi>=1.12 in /home/eric/.espressif/python_env/idf4.2_py3.6_env/lib/python3.6/site-packages (from cryptography>=2.1.4->-r /home/eric/esp/esp-idf/requirements.txt (line 11)) (1.14.5)Requirement already satisfied: six>=1.9.0 in /home/eric/.espressif/python_env/idf4.2_py3.6_env/lib/python3.6/site-packages (from ecdsa>=0.16.0->-r /home/eric/esp/esp-idf/requirements.txt (line 25)) (1.15.0)Requirement already satisfied: pycparser in /home/eric/.espressif/python_env/idf4.2_py3.6_env/lib/python3.6/site-packages (from cffi>=1.12->cryptography>=2.1.4->-r /home/eric/esp/esp-idf/requirements.txt (line 11)) (2.20)Requirement already satisfied: itsdangerous>=0.21 in /home/eric/.espressif/python_env/idf4.2_py3.6_env/lib/python3.6/site-packages (from Flask<1.0,>=0.12.2->gdbgui==0.13.2.0->-r /home/eric/esp/esp-idf/requirements.txt (line 15)) (1.1.0)Requirement already satisfied: Jinja2>=2.4 in /home/eric/.espressif/python_env/idf4.2_py3.6_env/lib/python3.6/site-packages (from Flask<1.0,>=0.12.2->gdbgui==0.13.2.0->-r /home/eric/esp/esp-idf/requirements.txt (line 15)) (2.11.3)Requirement already satisfied: Werkzeug<1.0,>=0.7 in /home/eric/.espressif/python_env/idf4.2_py3.6_env/lib/python3.6/site-packages (from Flask<1.0,>=0.12.2->gdbgui==0.13.2.0->-r /home/eric/esp/esp-idf/requirements.txt (line 15)) (0.16.1)Requirement already satisfied: brotli in /home/eric/.espressif/python_env/idf4.2_py3.6_env/lib/python3.6/site-packages (from Flask-Compress<2.0,>=1.4.0->gdbgui==0.13.2.0->-r /home/eric/esp/esp-idf/requirements.txt (line 15)) (1.0.9)Requirement already satisfied: python-socketio>=1.6.1 in /home/eric/.espressif/python_env/idf4.2_py3.6_env/lib/python3.6/site-packages (from Flask-SocketIO<3.0,>=2.9->gdbgui==0.13.2.0->-r /home/eric/esp/esp-idf/requirements.txt (line 15)) (5.1.0)Requirement already satisfied: greenlet>=0.4.14 in /home/eric/.espressif/python_env/idf4.2_py3.6_env/lib/python3.6/site-packages (from gevent<2.0,>=1.2.2->gdbgui==0.13.2.0->-r /home/eric/esp/esp-idf/requirements.txt (line 15)) (1.0.0)Requirement already satisfied: MarkupSafe>=0.23 in /home/eric/.espressif/python_env/idf4.2_py3.6_env/lib/python3.6/site-packages (from Jinja2>=2.4->Flask<1.0,>=0.12.2->gdbgui==0.13.2.0->-r /home/eric/esp/esp-idf/requirements.txt (line 15)) (1.1.1)Requirement already satisfied: bidict>=0.21.0 in /home/eric/.espressif/python_env/idf4.2_py3.6_env/lib/python3.6/site-packages (from python-socketio>=1.6.1->Flask-SocketIO<3.0,>=2.9->gdbgui==0.13.2.0->-r /home/eric/esp/esp-idf/requirements.txt (line 15)) (0.21.2)Requirement already satisfied: python-engineio>=4 in /home/eric/.espressif/python_env/idf4.2_py3.6_env/lib/python3.6/site-packages (from python-socketio>=1.6.1->Flask-SocketIO<3.0,>=2.9->gdbgui==0.13.2.0->-r /home/eric/esp/esp-idf/requirements.txt (line 15)) (4.0.1)All done! You can now run:  . ./export.sh
Code: Select all
eric@eric-virtual-machine:~/esp/esp-idf$ . ./export.shDetecting the Python interpreterChecking "python" ...Python 3.6.9"python" has been detectedAdding ESP-IDF tools to PATH...fatal: not a git repository (or any of the parent directories): .gitWARNING: Git describe was unsuccessul: Command '['git', 'describe']' returned non-zero exit status 128.Using Python interpreter in /home/eric/.espressif/python_env/idf4.2_py3.6_env/bin/pythonChecking if Python packages are up to date...Python requirements from /home/eric/esp/esp-idf/requirements.txt are satisfied.Added the following directories to PATH:  /home/eric/esp/esp-idf/components/esptool_py/esptool  /home/eric/esp/esp-idf/components/espcoredump  /home/eric/esp/esp-idf/components/partition_table  /home/eric/esp/esp-idf/components/app_update  /home/eric/.espressif/tools/xtensa-esp32-elf/esp-2020r3-8.4.0/xtensa-esp32-elf/bin  /home/eric/.espressif/tools/xtensa-esp32s2-elf/esp-2020r3-8.4.0/xtensa-esp32s2-elf/bin  /home/eric/.espressif/tools/esp32ulp-elf/2.28.51-esp-20191205/esp32ulp-elf-binutils/bin  /home/eric/.espressif/tools/esp32s2ulp-elf/2.28.51-esp-20191205/esp32s2ulp-elf-binutils/bin  /home/eric/.espressif/tools/openocd-esp32/v0.10.0-esp32-20200709/openocd-esp32/bin  /home/eric/.espressif/python_env/idf4.2_py3.6_env/binDone! You can now compile ESP-IDF projects.Go to the project directory and run:  idf.py build
然而,在实例项目的目录下,使用idf.py报错,报错信息如下:Code: Select all
eric@eric-virtual-machine:~/esp/esp-idf$ idf.pyTraceback (most recent call last):  File "/home/eric/esp/esp-idf/tools/idf.py", line 45, in     from idf_py_actions.tools import (executable_exists, idf_version, merge_action_lists, realpath)  # noqa: E402  File "/home/eric/esp/esp-idf/tools/idf_py_actions/tools.py", line 1, in     import clickModuleNotFoundError: No module named 'click'
请问如何解决呢?不胜感激!
                                   

回帖(1)

刘洋

2024-6-24 16:39:06
从您的描述来看,您已经成功地将ESP-IDF从v3.3更新到v4.2,并按照官方文档的要求进行了相应的操作。但是,您遇到了idf.py无法使用的问题。以下是一些建议来解决这个问题:

1. 确保Python环境正确:首先,请确保您的系统中安装了Python 3.6或更高版本。您可以使用以下命令检查Python版本:

```
python3 --version
```

2. 检查环境变量:确保您的环境变量已经正确设置。您可以在终端中运行以下命令来检查:

```
echo $PYTHONPATH
echo $PATH
```

确保输出结果中包含了ESP-IDF的路径,例如:

```
/home/eric/esp/esp-idf/v4.2/tools
```

3. 重新安装ESP-IDF:如果上述步骤都正确,但问题仍然存在,请尝试重新安装ESP-IDF。首先,删除当前的ESP-IDF目录:

```
rm -rf ~/esp/esp-idf
```

然后,从GitHub重新下载并解压v4.2版本的ESP-IDF:

```
wget https://github.com/espressif/esp-idf/archive/v4.2.zip
unzip v4.2.zip
mv esp-idf-4.2 ~/esp/esp-idf
```

4. 重新运行install.sh和export.sh脚本:

```
cd ~/esp/esp-idf
./install.sh
./export.sh
```

5. 检查idf.py:确保idf.py文件具有执行权限。您可以使用以下命令检查并修改权限:

```
chmod +x ~/esp/esp-idf/tools/idf.py
```

6. 尝试运行idf.py:在完成上述步骤后,尝试运行idf.py:

```
python3 ~/esp/esp-idf/tools/idf.py --help
```

如果问题仍然存在,请提供更多详细信息,例如错误消息或日志,以便我们更好地了解问题并提供解决方案。
举报

更多回帖

发帖
×
20
完善资料,
赚取积分