Repository navigation
Description
I used chatgpt to help me go through this issue and the report below is fully generated by chatgpt which I copied and pasted.
VS Code Python Environments extension generates incorrectly quoted file path when running Python scripts on macOS
Description
When running a Python script using VS Code's Run Python File command, the Python Environments extension appears to cause the file path to be incorrectly quoted.
The Python interpreter then raises a FileNotFoundError ([Errno 2] No such file or directory).
Running the same script manually in the VS Code terminal works correctly.
Disabling the Microsoft Python Environments extension for the workspace resolves the issue.
Environment
- Operating system: macOS Monterey 12.7.6
- Python interpreter:
/opt/anaconda3/bin/python - Python version: 3.13.5
- Shell: zsh
- Python environment: Anaconda (base)
- Editor: Visual Studio Code
- Affected extension: Microsoft Python Environments (
ms-python.vscode-python-envs) - Python Environments: 1.42.0
- Python: 2026.10.0
- Visual Studio Code version: 1.145.2
Steps to Reproduce
- Open a Python project in VS Code.
- Ensure the Microsoft Python and Python Environments extensions are enabled.
- Select
/opt/anaconda3/bin/pythonas the Python interpreter. - Create a Python script inside a folder containing spaces, for example
Leetcode Problems/Min Depth of Binary Tree. - Open the script and click Run Python File.
- Observe that Python reports
No such file or directory. - Disable the Python Environments extension for the workspace and reload VS Code.
- Run the same file again.
Actual Behavior
The Python extension logs show a command resembling:
/opt/anaconda3/bin/python '"/Users/.../Leetcode Problems/Min Depth of Binary Tree"'The single quotes cause the inner double quotes to be passed as literal characters in the filename.
Python then fails to locate the script.
Expected Behavior
VS Code should generate a correctly quoted command:
/opt/anaconda3/bin/python "/Users/.../Leetcode Problems/Min Depth of Binary Tree"The script should execute successfully.
Workaround
Disabling the Microsoft Python Environments extension for the workspace resolves the issue.
After disabling it, VS Code generates the correctly quoted command and the script executes successfully.
Additional Information
- The problem also occurs when selecting Run Python File in Dedicated Terminal.
- Running the script manually works correctly.
- Renaming the script to include a
.pyextension did not resolve the issue. - Disabling VS Code terminal shell integration did not resolve the issue.
- The Python Output logs also intermittently displayed
Unable to find workspace for given file.
The issue appears to involve an interaction between the Python Environments extension and the Python execution command.
Extension Logs
Before disabling Python Environments:
[info] Send text to terminal: /opt/anaconda3/bin/python '"/Users/.../Leetcode Problems/Min Depth of Binary Tree"'
After disabling Python Environments, the generated command used correct quoting and the script ran successfully.
Activity
dhmartin commentedon Nov 8, 2026
See microsoft/vscode-python#26274