Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug Report]: Error "Please use idf.py only in an ESP-IDF shell environment." when running idf.py from a special terminal (VSC-943) #769

Closed
iangregsondev opened this issue Jul 31, 2022 · 5 comments · Fixed by #776
Labels
bug-report Bug Report from users on Github (don't use this tag manually, its supposed to be used via the issue)

Comments

@iangregsondev
Copy link

Describe the bug

Opening the IDF Terminal using the following icon

image

Gives an error when trying to run idf.py

image

To Reproduce

Just open the terminal (terminal idf) from the lower toolbar button and type idf.py.

Expected behavior

Should recongnise its in the special terminal and not give an error message

Screenshots
See above

Environment (please complete the following information):

  • OS Name & Version: [e.g. MacOS X 10.14.5] Macox 12.4
  • VSCode Version: [e.g. 1.35.1] 1.69.2
  • ESP-IDF Version: [e.g. v3.2.2] 1.4.0
  • Python Version: [e.g. 2.7.10] Python 3.10.5

NOTE: You can use the ESP-IDF: Doctor command to generate a report of your configuration in your clipboard which you can copy here.

Output

---------------------------------------------- ESP-IDF Extension for Visual Studio Code report ---------------------------------------------
OS darwin arm64 21.5.0
System environment variable IDF_PYTHON_ENV_PATH
undefined
System environment variable PATH
/Users/ian/.sdkman/candidates/micronaut/current/bin:/Users/ian/.sdkman/candidates/java/current/bin:/Users/ian/.sdkman/candidates/gradle/current/bin:/Users/ian/.pyenv/shims:/Users/ian/.nvm/versions/node/v16.15.1/bin:/Users/ian/.gvm/pkgsets/go1.18.1/global/bin:/Users/ian/.gvm/gos/go1.18.1/bin:/Users/ian/.gvm/pkgsets/go1.18.1/global/overlay/bin:/Users/ian/.gvm/bin:/Users/ian/.gvm/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/MacGPG2/bin:/usr/local/share/dotnet:~/.dotnet/tools:/Library/Apple/usr/bin:/Users/ian/.cargo/bin:/Users/ian/.local/bin:/Users/ian/.local/bin:/Users/ian/jetbrains-shell-scripts:/Users/ian/flutter/bin
System environment variable PYTHON
undefined
Visual Studio Code version 1.69.2
Visual Studio Code language en
Visual Studio Code shell /bin/zsh
ESP-IDF Extension version 1.4.0
---------------------------------------------------- Extension configuration settings ------------------------------------------------------
ESP-ADF Path (idf.espAdfPath) ${env:ADF_PATH}
ESP-IDF Path (idf.espIdfPath) /Users/ian/esp/esp-idf
ESP-MDF Path (idf.espMdfPath) ${env:MDF_PATH}
Custom extra paths (idf.customExtraPaths) /Users/ian/.espressif/tools/xtensa-esp-elf-gdb/11.2_20220715/xtensa-esp-elf-gdb/bin:/Users/ian/.espressif/tools/riscv32-esp-elf-gdb/11.2_20220715/riscv32-esp-elf-gdb/bin:/Users/ian/.espressif/tools/xtensa-esp32-elf/esp-2022r1-RC1-11.2.0/xtensa-esp32-elf/bin:/Users/ian/.espressif/tools/xtensa-esp32s2-elf/esp-2022r1-RC1-11.2.0/xtensa-esp32s2-elf/bin:/Users/ian/.espressif/tools/xtensa-esp32s3-elf/esp-2022r1-RC1-11.2.0/xtensa-esp32s3-elf/bin:/Users/ian/.espressif/tools/riscv32-esp-elf/esp-2022r1-RC1-11.2.0/riscv32-esp-elf/bin:/Users/ian/.espressif/tools/esp32ulp-elf/2.28.51-esp-20191205/esp32ulp-elf-binutils/bin:/Users/ian/.espressif/tools/esp32s2ulp-elf/2.28.51-esp-20191205/esp32s2ulp-elf-binutils/bin:/Users/ian/.espressif/tools/openocd-esp32/v0.11.0-esp32-20220706/openocd-esp32/bin
Custom extra vars (idf.customExtraVars) {"OPENOCD_SCRIPTS":"/Users/ian/.espressif/tools/openocd-esp32/v0.11.0-esp32-20220706/openocd-esp32/share/openocd/scripts"}
Virtual env Python Path (idf.pythonBinPath) /Users/ian/.espressif/python_env/idf5.0_py3.10_env/bin/python
Serial port (idf.port) /dev/cu.usbmodem1113201
OpenOCD Configs (idf.openOcdConfigs) board/esp32s3-bridge.cfg
ESP-IDF Tools Path (idf.toolsPath) /Users/ian/.espressif
Git Path (idf.gitPath) /opt/homebrew/bin/git
-------------------------------------------------------- Configurations access -------------------------------------------------------------
Access to ESP-ADF Path (idf.espAdfPath) false
Access to ESP-IDF Path (idf.espIdfPath) true
Access to ESP-MDF Path (idf.espMdfPath) false
Access to ESP-IDF Custom extra paths
Access to /Users/ian/.espressif/tools/xtensa-esp-elf-gdb/11.2_20220715/xtensa-esp-elf-gdb/bin: true
Access to /Users/ian/.espressif/tools/riscv32-esp-elf-gdb/11.2_20220715/riscv32-esp-elf-gdb/bin: true
Access to /Users/ian/.espressif/tools/xtensa-esp32-elf/esp-2022r1-RC1-11.2.0/xtensa-esp32-elf/bin: true
Access to /Users/ian/.espressif/tools/xtensa-esp32s2-elf/esp-2022r1-RC1-11.2.0/xtensa-esp32s2-elf/bin: true
Access to /Users/ian/.espressif/tools/xtensa-esp32s3-elf/esp-2022r1-RC1-11.2.0/xtensa-esp32s3-elf/bin: true
Access to /Users/ian/.espressif/tools/riscv32-esp-elf/esp-2022r1-RC1-11.2.0/riscv32-esp-elf/bin: true
Access to /Users/ian/.espressif/tools/esp32ulp-elf/2.28.51-esp-20191205/esp32ulp-elf-binutils/bin: true
Access to /Users/ian/.espressif/tools/esp32s2ulp-elf/2.28.51-esp-20191205/esp32s2ulp-elf-binutils/bin: true
Access to /Users/ian/.espressif/tools/openocd-esp32/v0.11.0-esp32-20220706/openocd-esp32/bin: true
Access to Virtual env Python Path (idf.pythonBinPath) true
Access to CMake in environment PATH true
Access to Ninja in environment PATH true
Access to ESP-IDF Tools Path (idf.toolsPath) true
----------------------------------------------------------- Executables Versions -----------------------------------------------------------
Git version 2.37.1
ESP-IDF version 5.0
Python version 3.10.5
Python's pip version 22.2.1
-------------------------------------------------- Python packages in idf.pythonBinPath ----------------------------------------------------
bitstring version: 3.1.9
certifi version: 2022.6.15
cffi version: 1.15.1
charset-normalizer version: 2.1.0
click version: 8.0.4
colorama version: 0.4.5
construct version: 2.10.68
contextlib2 version: 21.6.0
cryptography version: 36.0.2
ecdsa version: 0.18.0
esp-coredump version: 1.2
esptool version: 4.1
freertos-gdb version: 1.0.1
future version: 0.18.2
gcovr version: 5.1
idf-component-manager version: 1.1.4
idna version: 3.3
Jinja2 version: 3.1.2
kconfiglib version: 14.1.0
lxml version: 4.9.1
MarkupSafe version: 2.1.1
pip version: 22.2.1
psutil version: 5.9.1
pycparser version: 2.21
pyelftools version: 0.27
pygdbmi version: 0.9.0.2
Pygments version: 2.12.0
pyparsing version: 3.0.9
pyserial version: 3.5
PyYAML version: 6.0
reedsolo version: 1.5.4
requests version: 2.28.1
requests-toolbelt version: 0.9.1
schema version: 0.7.5
setuptools version: 63.2.0
six version: 1.16.0
tqdm version: 4.64.0
urllib3 version: 1.26.11
websocket-client version: 1.3.3
wheel version: 0.37.1
xmlrunner version: 1.7.7
---------------------------------------------------- Check ESP-IDF python requirements.txt -------------------------------------------------
Check ESP-IDF Python packages Error
---------------------------------------------------- Check extension requirements.txt ------------------------------------------------------
Check Extension Python packages Python requirements are satisfied.
---------------------------------------------------- Check ESP-IDF debug adapter requirements.txt ------------------------------------------
Check Debug AdapterPython packages Python requirements are satisfied.
---------------------------------------------------- Visual Studio Code launch.json --------------------------------------------------------
{
"version": "0.2.0",
"configurations": [
{
"type": "espidf",
"name": "Launch",
"request": "launch"
}
]
}
---------------------------------------------------- Visual Studio Code c_cpp_properties.json ----------------------------------------------
{
"configurations": [
{
"name": "ESP-IDF",
"compilerPath": "/Users/ian/.espressif/tools/xtensa-esp32-elf/esp-2022r1-RC1-11.2.0/xtensa-esp32-elf/bin/xtensa-esp32-elf-gcc",
"cStandard": "c11",
"cppStandard": "c++17",
"includePath": [
"${config:idf.espIdfPath}/components/",
"${config:idf.espIdfPathWin}/components/
",
"${config:idf.espAdfPath}/components/",
"${config:idf.espAdfPathWin}/components/
",
"${workspaceFolder}/"
],
"browse": {
"path": [
"${config:idf.espIdfPath}/components",
"${config:idf.espIdfPathWin}/components",
"${config:idf.espAdfPath}/components/
",
"${config:idf.espAdfPathWin}/components/**",
"${workspaceFolder}"
],
"limitSymbolsToIncludedHeaders": false
}
}
],
"version": 4
}

----------------------------------------------------------- Latest error -----------------------------------------------------------------
Latest error at Command failed: /Users/ian/.espressif/python_env/idf5.0_py3.10_env/bin/python /Users/ian/esp/esp-idf/tools/check_python_dependencies.py -r "/Users/ian/esp/esp-idf/requirements.txt"
Traceback (most recent call last):
File "/Users/ian/esp/esp-idf/tools/check_python_dependencies.py", line 40, in
with open(req_path) as f:
FileNotFoundError: [Errno 2] No such file or directory: '/Users/ian/esp/esp-idf/requirements.txt'


In Visual Studio Code select menu View -> Output -> ESP-IDF, ESP-IDF Debug Adapter, Heap Trace, OpenOCD and SDK Configuration Editor.

NOTE: Use idf.openOcdDebugLevel configuration setting to 3 or more to show debug logging in OpenOCD server output.

NOTE: Use logLevel in your /.vscode/launch.json to 3 or more to show more debug adapter output.

Please share the output of the channel related to your issue. For example ESP-IDF is used mostly for the extension setup process output.

Logs
Please share the log file which can be obtained from:

  • Windows: %USERPROFILE%\.vscode\extensions\espressif.esp-idf-extension-VERSION\esp_idf_vsc_ext.log
  • Linux & MacOSX: $HOME/.vscode/extensions/espressif.esp-idf-extension-VERSION/esp_idf_vsc_ext.log

Extension Configuration settings
Open Command Palette (F1 or View Menu -> Command Palette) and type Preferences: Open Settings (JSON) or use {CURRENT_PROJECT}/.vscode/settings.json to get the following extension configuration settings value:

  • idf.espIdfPath (MacOS or Linux) or idf.espIdfPathWin (Windows) also called Path to locate ESP-IDF framework (IDF_PATH) in Preferences: Open Settings (UI).
  • idf.pythonBinPath (MacOS or Linux) or idf.pythonBinPathWin (Windows) also called Python absolute binary path used to execute ESP-IDF Python Scripts in Preferences: Open Settings (UI).
  • idf.openOcdConfigs also called List of configuration files inside OpenOCD Scripts directory in Preferences: Open Settings (UI).
  • idf.customExtraPaths also called Paths to be appended to PATH in Preferences: Open Settings (UI).
  • idf.customExtraVars also called Variables to be added to system environment variables in Preferences: Open Settings (UI).
  • idf.adapterTargetName also called Target name for ESP-IDF Debug Adapter in Preferences: Open Settings (UI).
  • idf.customAdapterTargetName is used when idf.adapterTargetName is set to custom.

Additional context
Add any other context about the problem here.

@iangregsondev iangregsondev added the bug-report Bug Report from users on Github (don't use this tag manually, its supposed to be used via the issue) label Jul 31, 2022
@iangregsondev iangregsondev changed the title [Bug Report]: [Bug Report]: Error "Please use idf.py only in an ESP-IDF shell environment." when running idf.py from a special terminal Jul 31, 2022
@github-actions github-actions bot changed the title [Bug Report]: Error "Please use idf.py only in an ESP-IDF shell environment." when running idf.py from a special terminal [Bug Report]: Error "Please use idf.py only in an ESP-IDF shell environment." when running idf.py from a special terminal (VSC-943) Jul 31, 2022
@iangregsondev
Copy link
Author

I can run the following command manually inside the special terminal and things start to work..

. ~/esp/esp-idf/export.sh

Although this is a manual process and probably should not need to be done.

@brianignacio5
Copy link
Collaborator

Hi @iangregsondev I've noticed that some tools were not being installed (those tar.xz) and the linked PR should fix the issue.

Could you try this vsix installer and see if it works for you ?

@arikon
Copy link

arikon commented May 1, 2023

@brianignacio5 The problem (Please use idf.py only in an ESP-IDF shell environment when trying to run idf.py in a terminal) remains in the last version of extension (v1.6.1)

@arikon
Copy link

arikon commented May 2, 2023

@brianignacio5 Created new issue #959

@crack-dawn
Copy link

Yes, indeed! For those using Visual Studio Code with the ESP-IDF extension, you can create a new ESP-IDF component without having to manually activate the ESP-IDF shell environment through the command line. Here's how:

  1. Open your ESP-IDF project in Visual Studio Code.

  2. Press Ctrl + Shift + P (or Cmd + Shift + P on macOS) to open the Command Palette.

  3. Type "ESP-IDF: Create Component" in the search field of the Command Palette.
    image

  4. Select this command when it appears.

  5. Input your component name.
    image

  6. Here, two user-defined components have been created, one called LED and the other called nowMy.
    image

This action will prompt you for the name of the component and where to create it within your ESP-IDF project directory structure. The extension takes care of activating the correct environment and running the necessary idf.py commands under the hood to create the component.

By leveraging the ESP-IDF extension in VSCode, you benefit from integrated development environment features that simplify many common ESP-IDF development tasks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug-report Bug Report from users on Github (don't use this tag manually, its supposed to be used via the issue)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants