I'm trying to run idf.py as a CMD command. I've set my env variables it's still not recognizing
Asked Answered
G

5

5

I've set up my environment variables to use the esp32 toolchain. One of the core functions is idf.py which needs to be accessible from the terminal.

If i try to access it in VS Code i get

idf.py : The term 'idf.py' is not recognized as the name of a cmdlet, 
function, script file, oroperable program. Check the spelling of the 
name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ idf.py
+ ~~~~~~
+ CategoryInfo          : ObjectNotFound: (idf.py:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException

Here is a picture of my echo %path% where you can see that I've explicitly stated that idf.py.exe is a path. Unfortunately I'm pretty stuck and not sure what the next step is from here.

Gradual answered 27/8, 2020 at 11:42 Comment(3)
I think you are mixing idf.py and idf.exe - isnt it?Rieth
If you take a look through your over-bloated %PATH% values, you should see a specific pattern, except in the particular item you've highlighted. The values are supposed to be the parent directories of the executable files, not the files themselves! I will strongly recommend that you edit the environment variables, (USER and SYSTEM), in the GUI to remove duplicate, incorrect, and no longer needed entries, and to also ensure that the main five, `C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\; are at the top.Armenian
Cheers compo, ill give that a go. idf.exe did not work sorry.Gradual
U
6

To set up and run ESP-IDF commands, follow these steps:

Solution 1

  1. Navigate to ESP-IDF install folder cd d:\my_esp_idf
  2. Run the install.bat (one time only after ESP-IDF framework installation, not for each example)
  3. Run the export.bat (this will add idf.py to you system environment path)
  4. Navigate to your example (e.g.: cd examples/get-started/hello_world)
  5. Build your example (e.g.: idf.py build)

Check this screenshot for a complete demo step-by-step

Solution 2

Run the ESP-IDF terminal (CMD or PowerShell). Go to this location C:\Users<user>\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\ESP-IDF and there you should find 2 terminal shortcuts ESP-IDF terminals

Open a terminal and start running idf.py commands

Unhealthy answered 26/3, 2023 at 11:42 Comment(0)
H
2

Kill terminal and Open ESP-IDF Terminal

Hypocrite answered 6/1, 2022 at 15:47 Comment(3)
Could you explain the intuition behind your suggestion?Faggoting
I got the same error and I understood that I couldn't open ESP-IDF terminal, it was a powershell in VS code so I kill terminal which is powershell and I opened Open ESP-IDF Terminal from Command Palette. Actually there is an one important thing that you need to make sure you download esp-idf correctly and you tried with ESP-IDF Powershell or ESP-IDF CMD. I hope this way can solve your problemHypocrite
Thank you for the answer. This is necessary when ESP-IDF was installed using VS code, rather than the standard installation process. For me this also fixed an issue where python was complaining about 'click' not being installed, even though it was. I was attempting to install the littlefs library for ESP32 as a managed component.Yasui
T
0

Had the same issue. Resolved by making sure my idf.espIdfPath (go to File, then Preferences, then Settings, and search for "idf.espIdfPath") was pointing to the right environment variable (mine was pointing to IDF_TOOLS from system environment variables, but should have been pointing to IDF_TOOLS_PATH instead). Fixed that, then restarted vscode from the ESP-IDF terminal by typing "code ." from the project directory. That seemed to do the trick. Worst case, and I recognize it's not the ideal option, perhaps reinstall vscode and all your required extensions?

Tackling answered 15/5, 2021 at 9:40 Comment(0)
A
0

You added the ESP-IDF tools to your Path, but they ended up lower priority than an existing Python install. So go into your System PATH env variable settings again and move the ESP-IDF tools entry to the very top.

Restart all terminals and VSCode. Then you'll get:

Please use idf.py only in an ESP-IDF shell environment.

So then follow up with the other answer that explains how to install that shell.

Affettuoso answered 12/6, 2023 at 18:0 Comment(0)
I
0

I gave up using VS Code for ESP32. I found this worked:

  • Run esp-idf-tools-setup-online-2.23.exe (or later) from Espressif. Note that the offline installer does not seem to install everything that is needed.

  • From the Windows start menu, open ESP-IDF 5.x PowerShell (not ESP-IDF 5.x CMD).

    cd C:\MyProjectFolder (wherever you put your project)

    idf.py menuconfig

Ideal answered 1/12, 2023 at 9:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.