idf.py not recognized

Jorgen
Posts: 52
Joined: Fri Dec 09, 2022 11:39 am

idf.py not recognized

Postby Jorgen » Sat Mar 25, 2023 2:33 pm

I have installed ESP-IDF version 5.0.1.
I use Windows 11.
I have added to the system environment variables IDF_PATH defined as C:\Espressif and included in the path %IDF_PATH%\tools.
When I use idf.py build I get: The term 'idf.py' is not recognized as a name ....

I have also run the ESF-IDF 5.0 CMD shortcut on the desktop that appeared when I installed the ESP-IDF 5.0.1. I ran it as administrator.

I still get the error The term 'idf.py' is not recognized as a name ....

Please, inform me on how to get idf.py working. The more details the better on how to set the environment variables.

I can build, flash and monitor when I use the command icons at the bottom of the screen. Despite this I would like idf.py working.

Regards,
Jorgen

tpbedford
Posts: 31
Joined: Mon Feb 14, 2022 4:16 am

Re: idf.py not recognized

Postby tpbedford » Mon Mar 27, 2023 1:53 am

Try running export.bat first, found in the IDF framework folder (e.g. C:\Espressif\frameworks\esp-idf-v4.4.3)

Add this path to PATH environment var and then when you need the idf.py tools you can run export.bat from any command path before then calling idf.py from your project folder.

User avatar
ESP_Roland
Posts: 265
Joined: Tue Oct 09, 2018 10:28 am

Re: idf.py not recognized

Postby ESP_Roland » Mon Mar 27, 2023 6:11 am

I recommend to you to remove all environment variables you set manually. They will cause you trouble now or later.

It is advised to use the Windows installer (https://docs.espressif.com/projects/esp ... setup.html) which will set up your environment.

Jorgen
Posts: 52
Joined: Fri Dec 09, 2022 11:39 am

Re: idf.py not recognized

Postby Jorgen » Mon Mar 27, 2023 9:56 am

I have used the ESP-IDF installer and then installed ESP-IDF in Visual Studio Code. I have configured it as well. When I did the installation I ensured the PowerShell and command shell were ticked.

I have found and run the export batch file in C:\Espressif\frameworks\esp-idf-v5.0.1, but it did not solve the problem.

When I look in the environment variables for the user and for the system, there is nothing related to ESP-IDF.

Now, running the PowerShell by double clicking the icon ESP-IDF 5.0 PowerShell on the desktop, the output is as shown in the file attached. When I write idf.py at the prompt at the end of the file it works, but it does not when I open VS code and the ESP-IDF.

Should that PowerShell be run within the ESP-IDF?
If so, how?
If so, how can I ensure this is done automatically each time I open the ESP-IDF?

I agree, I prefer not to touch by hand the settings in Windows such as environment variables, but it is annoying the idf.py command does not work in ESP-IDF, since some features are not available in any other way.

When I installed the ESP-IDF v5.0.1, I deinstalled the previous version 5.0 and VS Code first. The I installed the ESP-IDF v5.0.1 and after that VS Code. Then I started VS Code and added the ESP-IDF extension. Finally I configured the extension using the command ESP-IDF: Configure the ESP-IDF extension. It completed without any errors and declared the setup ready for use.

Is something not working with the installation of ESP-IDF on a 64 bit Windows 11 machine?

Thank you for your replies to my cry for help.

Regards,
Jorgen
Attachments
PowerShell.txt
(2.63 KiB) Downloaded 578 times

tpbedford
Posts: 31
Joined: Mon Feb 14, 2022 4:16 am

Re: idf.py not recognized

Postby tpbedford » Mon Mar 27, 2023 8:32 pm

For me, I run cmd as administrator, then execute export.bat once. From then I can use idf.py in that cmd session only. If I close and launch another cmd then I have to repeat the call to export.bat.

The first 1-2 times I used export.bat on a new 4.4.4 installation I was also required to run install.bat.

My relevant env vars (before running export.bat) are:
IDF_TOOLS_PATH=C:\Espressif
PATH=C:\Python311\Scripts\;C:\Python311\;C:\Espressif\tools\idf-git\2.34.2\cmd;C:\Users\me\AppData\Roaming\Python\Python311\Scripts;
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC;.PY;.PYW

Once I run export.bat this appears to add:
IDF_CCACHE_ENABLE=1
IDF_PATH=C:\Espressif\frameworks\esp-idf
IDF_PYTHON_ENV_PATH=C:\Espressif\python_env\idf4.4_py3.11_env

and these are added to PATH:
C:\Espressif\tools\xtensa-esp-elf-gdb\11.2_20220823\xtensa-esp-elf-gdb\bin;
C:\Espressif\tools\riscv32-esp-elf-gdb\11.2_20220823\riscv32-esp-elf-gdb\bin;
C:\Espressif\tools\xtensa-esp32-elf\esp-2021r2-patch5-8.4.0\xtensa-esp32-elf\bin;
C:\Espressif\tools\xtensa-esp32s2-elf\esp-2021r2-patch5-8.4.0\xtensa-esp32s2-elf\bin;
C:\Espressif\tools\xtensa-esp32s3-elf\esp-2021r2-patch5-8.4.0\xtensa-esp32s3-elf\bin;
C:\Espressif\tools\riscv32-esp-elf\esp-2021r2-patch5-8.4.0\riscv32-esp-elf\bin;
C:\Espressif\tools\esp32ulp-elf\2.35_20220830\esp32ulp-elf\bin;
C:\Espressif\tools\cmake\3.23.1\bin;
C:\Espressif\tools\openocd-esp32\v0.11.0-esp32-20221026\openocd-esp32\bin;
C:\Espressif\tools\ninja\1.10.2\;
C:\Espressif\tools\idf-exe\1.0.3\;
C:\Espressif\tools\ccache\4.3\ccache-4.3-windows-64;
C:\Espressif\tools\dfu-util\0.9\dfu-util-0.9-win64;
C:\Espressif\python_env\idf4.4_py3.11_env\Scripts;
C:\Espressif\frameworks\esp-idf\tools;
C:\Espressif\tools\idf-git\2.34.2\cmd;

I don't use Powershell.

Jorgen
Posts: 52
Joined: Fri Dec 09, 2022 11:39 am

Re: idf.py not recognized

Postby Jorgen » Tue Mar 28, 2023 9:58 am

Dear tpbedford,
Thank you for your reply. I will try it, but I have a nagging feeling that there must be a way to make idf.py available automatically at start up of the ESP-IDF. It seems the running of the PowerShell sets some path parameters that are valid only within the command window opened by PowerShell just like the export.bat sets path parameters temporarily.

I hope someone from the ESP-IDF team also reads this and will take action and make it easy for people like me to use the VS Code + ESP-IDF, that wants to develop code and not dig around in ESP-IDF folders and files.

Regards,
Jorgen

PS. I have searched the internet and found some guidance in the ESP-IDF documentation, but that is not up to date for v5.0.1.

User avatar
ESP_Roland
Posts: 265
Joined: Tue Oct 09, 2018 10:28 am

Re: idf.py not recognized

Postby ESP_Roland » Tue Mar 28, 2023 1:42 pm

If you prefer to use vscode then please follow the instructions on this page: https://github.com/espressif/vscode-esp-idf-extension, especially https://github.com/espressif/vscode-esp ... install.md.

joseMiguel
Posts: 22
Joined: Sun Oct 25, 2020 11:43 pm

Re: idf.py not recognized

Postby joseMiguel » Tue Mar 28, 2023 3:09 pm

Hi Jorgen

Here below in the .vscode directory
the settings.json file (User Profile)

Code: Select all

{
    "C_Cpp.intelliSenseEngine": "Tag Parser",
    "idf.adapterTargetName": "esp32c3",
    "idf.customExtraPaths": "C:\\Users\\josem\\.espressif\\tools\\xtensa-esp-elf-gdb\\11.2_20220823\\xtensa-esp-elf-gdb\\bin;C:\\Users\\josem\\.espressif\\tools\\riscv32-esp-elf-gdb\\11.2_20220823\\riscv32-esp-elf-gdb\\bin;C:\\Users\\josem\\.espressif\\tools\\xtensa-esp32-elf\\esp-2022r1-11.2.0\\xtensa-esp32-elf\\bin;C:\\Users\\josem\\.espressif\\tools\\xtensa-esp32s2-elf\\esp-2022r1-11.2.0\\xtensa-esp32s2-elf\\bin;C:\\Users\\josem\\.espressif\\tools\\xtensa-esp32s3-elf\\esp-2022r1-11.2.0\\xtensa-esp32s3-elf\\bin;C:\\Users\\josem\\.espressif\\tools\\riscv32-esp-elf\\esp-2022r1-11.2.0\\riscv32-esp-elf\\bin;C:\\Users\\josem\\.espressif\\tools\\esp32ulp-elf\\2.35_20220830\\esp32ulp-elf\\bin;C:\\Users\\josem\\.espressif\\tools\\cmake\\3.24.0\\bin;C:\\Users\\josem\\.espressif\\tools\\openocd-esp32\\v0.11.0-esp32-20221026\\openocd-esp32\\bin;C:\\Users\\josem\\.espressif\\tools\\ninja\\1.10.2;C:\\Users\\josem\\.espressif\\tools\\idf-exe\\1.0.3;C:\\Users\\josem\\.espressif\\tools\\ccache\\4.6.2\\ccache-4.6.2-windows-x86_64;C:\\Users\\josem\\.espressif\\tools\\dfu-util\\0.9\\dfu-util-0.9-win64",
    "idf.customExtraVars": {
        "OPENOCD_SCRIPTS": "C:\\Users\\josem\\.espressif\\tools\\openocd-esp32\\v0.11.0-esp32-20221026/openocd-esp32/share/openocd/scripts",
        "GDB":"C:\\Users\\josem\\.espressif\\tools\\riscv32-esp-elf-gdb\\11.2_20220823\\riscv32-esp-elf-gdb\\bin",
        "IDF_CCACHE_ENABLE": "1"
    },
    "idf.espIdfPathWin": "c:\\ESP\\esp-idf-v5.0",
    "idf.openOcdLaunchArgs": [
        "-s ../share/openocd/scripts/",
        "-f interface/esp_usb_jtag.cfg",
        "-f board/esp32c3-builtin.cfg"
    ],
    "idf.openOcdScriptValue": "openocd-esp32/share/openocd/scripts/",
    "idf.openOcdConfigs": [
        "interface/esp_usb_jtag.cfg",
        "board/esp32c3-builtin.cfg"
    ],
    "idf.portWin": "COM11",
    "idf.pythonBinPathWin": "C:\\Users\\josem\\.espressif\\python_env\\idf5.0_py3.8_env\\Scripts\\python.exe",
    "idf.toolsPathWin": "C:\\Users\\josem\\.espressif"
}
C:\Users\josem\AppData\Roaming\Code\User\setting.json for VSCode and IDF configuration (Working Space Profile)

Code: Select all

{
    "workbench.colorTheme": "Default Dark+",
    "idf.adapterTargetName": "esp32c3",
    "idf.customExtraPaths": "C:\\Users\\josem\\.espressif\\tools\\xtensa-esp-elf-gdb\\11.2_20220823\\xtensa-esp-elf-gdb\\bin;C:\\Users\\josem\\.espressif\\tools\\riscv32-esp-elf-gdb\\11.2_20220823\\riscv32-esp-elf-gdb\\bin;C:\\Users\\josem\\.espressif\\tools\\xtensa-esp32-elf\\esp-2022r1-11.2.0\\xtensa-esp32-elf\\bin;C:\\Users\\josem\\.espressif\\tools\\xtensa-esp32s2-elf\\esp-2022r1-11.2.0\\xtensa-esp32s2-elf\\bin;C:\\Users\\josem\\.espressif\\tools\\xtensa-esp32s3-elf\\esp-2022r1-11.2.0\\xtensa-esp32s3-elf\\bin;C:\\Users\\josem\\.espressif\\tools\\riscv32-esp-elf\\esp-2022r1-11.2.0\\riscv32-esp-elf\\bin;C:\\Users\\josem\\.espressif\\tools\\esp32ulp-elf\\2.35_20220830\\esp32ulp-elf\\bin;C:\\Users\\josem\\.espressif\\tools\\cmake\\3.24.0\\bin;C:\\Users\\josem\\.espressif\\tools\\openocd-esp32\\v0.11.0-esp32-20221026\\openocd-esp32\\bin;C:\\Users\\josem\\.espressif\\tools\\ninja\\1.10.2;C:\\Users\\josem\\.espressif\\tools\\idf-exe\\1.0.3;C:\\Users\\josem\\.espressif\\tools\\ccache\\4.6.2\\ccache-4.6.2-windows-x86_64;C:\\Users\\josem\\.espressif\\tools\\dfu-util\\0.9\\dfu-util-0.9-win64",
    //"python.defaultInterpreterPath": "C:\\Users\\josem\\.espressif\\python_env\\idf5.0_py3.8_env\\Scripts\\python.exe",
	"python.defaultInterpreterPath":"C:\\Users\\josem\\AppData\\Local\\Programs\\Python\\Python39\\python.exe",
    "idf.flashType": "UART",
	"idf.openOcdScriptValue": "openocd-esp32/share/openocd/scripts/",
    "idf.openOcdConfigs": [

        "interface/esp_usb_jtag.cfg",
        "board/esp32c3-builtin.cfg"
    ],
    "idf.portWin": "COM11",
    "idf.openOcdDebugLevel": 4,
    "openocd.tcl.host": "localhost",
    "openocd.tcl.port": 6666,
    "git.autorefresh": false,
    "idf.launchMonitorOnDebugSession": true,
    
    "terminal.integrated.automationProfile.windows": {},
    "terminal.integrated.defaultProfile.windows": "PowerShell",
    "[python]": {
        "editor.formatOnType": true
    },
    "C_Cpp.default.customConfigurationVariables": {},
    "platformio-ide.customPATH": "",
    "idf.gitPathWin": "C:\\Users\\josem\\.espressif\\tools\\idf-git\\2.30.1\\cmd\\git.exe",
    "idf.espIdfPathWin": "c:\\ESP\\esp-idf-v5.0",
    //"idf.pythonBinPathWin": "C:\\Users\\josem\\.espressif\\python_env\\idf5.1_py3.9_env",
	"idf.pythonBinPathWin": "C:\\Users\\josem\\.espressif\\python_env\\idf5.0_py3.8_env\\Scripts\\python.exe",
    "idf.toolsPathWin": "C:\\Users\\josem\\.espressif",
    "idf.customExtraVars": {
        "OPENOCD_SCRIPTS": "C:\\Users\\josem\\.espressif\\tools\\openocd-esp32\\v0.11.0-esp32-20221026/openocd-esp32/share/openocd/scripts",
        "IDF_CCACHE_ENABLE": "1"
    },
    "terminal.integrated.env.windows": {},
    "debug.allowBreakpointsEverywhere": true
    
}
After having those two configurations
Type
1) install.bat
2) export.bat
...
Normally idf.py is found now

Hope it helps you
Kind regards

José Michel
José Michel

Jorgen
Posts: 52
Joined: Fri Dec 09, 2022 11:39 am

Re: idf.py not recognized

Postby Jorgen » Wed Mar 29, 2023 8:37 am

Dear ESP_Roland,
I have followed your advice and re-installed ESP-IDF v5.0.1 using the ESP-IDF configuration command within the VS Code. It did not change the behavior. idf.py is still not recognized.

Is there a log file or similar that would allow to check my installation?

Dear joseMiguel,
My versions are rather different of the two files, which you have included in your reply. I have copied my version of the C:\Users\jorgeAppData\Roaming\Code\User\setting.json
{
"idf.gitPathWin": "c:\\Espressif\\tools\\idf-git\\2.30.1\\cmd\\git.exe",
"idf.espIdfPathWin": "C:\\Users\\jorge\\esp\\esp-idf",
"idf.pythonBinPathWin": "c:\\Espressif\\python_env\\idf5.0_py3.8_env\\Scripts\\python.exe",
"idf.toolsPathWin": "c:\\Espressif",
"idf.customExtraPaths": "c:\\Espressif\\tools\\xtensa-esp-elf-gdb\\11.2_20220823\\xtensa-esp-elf-gdb\\bin;c:\\Espressif\\tools\\riscv32-esp-elf-gdb\\11.2_20220823\\riscv32-esp-elf-gdb\\bin;c:\\Espressif\\tools\\xtensa-esp32-elf\\esp-2022r1-11.2.0\\xtensa-esp32-elf\\bin;c:\\Espressif\\tools\\xtensa-esp32s2-elf\\esp-2022r1-11.2.0\\xtensa-esp32s2-elf\\bin;c:\\Espressif\\tools\\xtensa-esp32s3-elf\\esp-2022r1-11.2.0\\xtensa-esp32s3-elf\\bin;c:\\Espressif\\tools\\riscv32-esp-elf\\esp-2022r1-11.2.0\\riscv32-esp-elf\\bin;c:\\Espressif\\tools\\esp32ulp-elf\\2.35_20220830\\esp32ulp-elf\\bin;c:\\Espressif\\tools\\cmake\\3.24.0\\bin;c:\\Espressif\\tools\\openocd-esp32\\v0.11.0-esp32-20221026\\openocd-esp32\\bin;c:\\Espressif\\tools\\ninja\\1.10.2;c:\\Espressif\\tools\\idf-exe\\1.0.3;c:\\Espressif\\tools\\ccache\\4.6.2\\ccache-4.6.2-windows-x86_64;c:\\Espressif\\tools\\dfu-util\\0.9\\dfu-util-0.9-win64;c:\\Espressif\\tools\\esp-rom-elfs\\20220823",
"idf.customExtraVars": {
"OPENOCD_SCRIPTS": "c:\\Espressif\\tools\\openocd-esp32\\v0.11.0-esp32-20221026/openocd-esp32/share/openocd/scripts",
"IDF_CCACHE_ENABLE": "1",
"ESP_ROM_ELF_DIR": "c:\\Espressif\\tools\\esp-rom-elfs\\20220823/"
},
"editor.accessibilitySupport": "off",
"[python]": {
"editor.formatOnType": true
},
"security.workspace.trust.untrustedFiles": "open"
}


When you write type "install.bat" and "export.bat", at which prompt should I do it? When I type one of them at the terminal prompt line within the ESP-ID in VS Code, they are both unrecognized.

Sorry to be so inexperienced.

Regards,
Jorgen

joseMiguel
Posts: 22
Joined: Sun Oct 25, 2020 11:43 pm

Re: idf.py not recognized

Postby joseMiguel » Wed Mar 29, 2023 9:51 am

Hi Jorgen,

In my .vscode directory of the ESP-IDF project
settings.json

Code: Select all

//...
"idf.espIdfPathWin": "c:\\ESP\\esp-idf-v5.0",
//...
"idf.toolsPathWin": "C:\\Users\\josem\\.espressif"
C:\Users\josem\AppData\Roaming\Code\User\settings.json

Code: Select all

//...
"idf.espIdfPathWin": "c:\\ESP\\esp-idf-v5.0",
//...
"idf.toolsPathWin": "C:\\Users\\josem\\.espressif",
//...
My environment system variable is
IDF_PATH c:\ESP\esp-idf-v5.0
IDF_TOOLS_PATH C:\Users\josem\.espressif
EXTENSION_PATH C:\Users\josem\.vscode\extensions\espressif.esp-idf-extension-1.6.0

I think that you must specify the esp-idf version, otherwise it could not be able to find idf.py for example.

Kind regards

José Michel
José Michel

Who is online

Users browsing this forum: No registered users and 89 guests