espressif / vscode-esp-idf-extension

Visual Studio Code extension for ESP-IDF projects
https://docs.espressif.com/projects/vscode-esp-idf-extension/en/latest/
Apache License 2.0
1.07k stars 305 forks source link

Windows - The script files in path C:\Users\{user}\.espressif\python_env\idf5.3_py3.11_env\Scripts will report an error when executed in ESP-IDF Terminal (VSC-1489) #1310

Open xinkunlong opened 2 months ago

xinkunlong commented 2 months ago

OS

Windows

Operating System version

Windows 11

Visual Studio Code version

Version: 1.93.0 (user setup) Commit: 4849ca9bdf9666755eb463db297b69e5385090e3 Date: 2024-09-04T13:02:38.431Z Electron: 30.4.0 ElectronBuildId: 10073054 Chromium: 124.0.6367.243 Node.js: 20.15.1 V8: 12.4.254.20-electron.0 OS: Windows_NT x64 10.0.22631

ESP-IDF version

5.3.1

Python version

3.11.2

Doctor command output

esptool.py help
PS C:\Users\kunlo\Downloads> ^C\Users\kunlo\.espressif\python_env\idf5.3_py3.11_env\Scripts\esptool.py:2
PS C:\Users\kunlo\Downloads> 
^

SyntaxError: Invalid or unexpected token
    at wrapSafe (node:internal/modules/cjs/loader:1288:20)
    at Module._compile (node:internal/modules/cjs/loader:1328:27)
    at Module._extensions..js (node:internal/modules/cjs/loader:1432:10)
    at Module.load (node:internal/modules/cjs/loader:1215:32)
    at Module._load (node:internal/modules/cjs/loader:1031:12)
    at c._load (node:electron/js2c/node_init:2:13801)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:189:12)
    at node:internal/main/run_main_module:28:49

Node.js v20.15.1
hex2bin.py help
PS C:\Users\kunlo\Downloads> C:\Users\kunlo\.espressif\python_env\idf5.3_py3.11_env\Scripts\hex2bin.py:3
# Copyright (c) 2005-2018 Alexander Belchenko
^

SyntaxError: Invalid or unexpected token
    at wrapSafe (node:internal/modules/cjs/loader:1288:20)
    at Module._compile (node:internal/modules/cjs/loader:1328:27)
    at Module._extensions..js (node:internal/modules/cjs/loader:1432:10)
    at Module.load (node:internal/modules/cjs/loader:1215:32)
    at Module._load (node:internal/modules/cjs/loader:1031:12)
    at c._load (node:electron/js2c/node_init:2:13801)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:189:12)
    at node:internal/main/run_main_module:28:49

Node.js v20.15.1

Extension

esp_idf_vsc_ext.log

Description

The script files in path C:\Users\{user}\.espressif\python_env\idf5.3_py3.11_env\Scripts will report an error when executed in ESP-IDF Terminal

Debug Message

esptool.py help
PS C:\Users\kunlo\Downloads> C:\Users\kunlo\.espressif\python_env\idf5.3_py3.11_env\Scripts\esptool.py:2
#
^

SyntaxError: Invalid or unexpected token
    at wrapSafe (node:internal/modules/cjs/loader:1288:20)
    at Module._compile (node:internal/modules/cjs/loader:1328:27)
    at Module._extensions..js (node:internal/modules/cjs/loader:1432:10)
    at Module.load (node:internal/modules/cjs/loader:1215:32)
    at Module._load (node:internal/modules/cjs/loader:1031:12)
    at c._load (node:electron/js2c/node_init:2:13801)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:189:12)
    at node:internal/main/run_main_module:28:49

Node.js v20.15.1


### Other Steps to Reproduce

_No response_

### I have checked existing issues, online documentation and the Troubleshooting Guide

- [X] I confirm I have checked existing issues, online documentation and Troubleshooting guide.
github-actions[bot] commented 1 month ago

This issue has been marked as stale since there are no activities, and this will be closed in 5 days if there are no further activities

radurentea commented 1 month ago

Hi @xinkunlong,

Thank you for reporting this bug. After investigating, I've identified the root cause:

The issue stems from the default program setting for .py files on your Windows machine. It appears you've set .py files to open with "VS Code" by default.

Workaround: Change the default program for .py files to the Python executable in your PATH: "C:\Users\kunlo.espressif\python_env\idf5.3_py3.11_env\Scripts\python.exe"

This should resolve the immediate issue. I'm still investigating a permanent solution to prevent this behavior. I'll update you once I have more information.

Let me know if you need any clarification or assistance implementing the workaround.