You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Run Python File passes literal quotes in script path to terminal #26274
The top-right Run Python File button fails when the Python script is in a path containing spaces and Python Environments handles terminal execution.
Expected: Python runs the selected file.
Actual: The terminal receives a script argument with literal double quotation marks inside single quotes. Redacted equivalent of the observed command:
/usr/local/bin/python3 '"/path with spaces/main.py"'
Python reports [Errno 2] No such file or directory because the double quotation marks become part of the filename. The error path includes the current directory followed by "/path with spaces/main.py" instead of the actual script path.
Steps to reproduce
Install and enable the Python and Python Environments extensions.
Open a Python file inside a directory with spaces in its path.
Click the top-right Run Python File button.
Observe the terminal command and error.
Running the same script directly with a correctly quoted shell path succeeds.
Diagnostic data
VS Code: 1.145.0 (arm64)
Python extension: 2026.10.0
Python Environments extension: 1.42.0
Python interpreter: 3.14.7 at /usr/local/bin/python3
I'm not sure about this but perhaps the last update flipped the 'Use Environments Extension' toggle on? There is a mention in the Python settings that the default value changed.
Flipping this off fixes the problem temporarily until the real fix comes. Or using the debugger.
Thanks to everyone who reproduced this. A Windows report shows the same literal quotes in the script path, so this affects both PowerShell and Zsh.
I looked into the timing. The Python extension has passed a pre-quoted script path to Python Environments since #25405. Python Environments #1946 later changed terminal execution to quote arguments for Zsh and PowerShell. Together, those changes appear to produce the literal quotes in these reports.
That later change shipped in Python Environments 1.42.0 on November 4, the same evening my installation updated. This strongly suggests the update exposed the mismatch.
PR #26275 addresses it by passing the script path without added quotes.
Thanks for looking into this. #26275 and #26276 both address the quoting issue in executeUsingExtension, so I wanted to flag the overlap.
#26275 includes regression coverage for all three Run Python File commands, including the top-right icon, across several path cases. I also verified the patched extension inside VS Code on macOS. That check does not establish PowerShell behavior, but the test coverage may be useful when finalizing the fix.
I reproduced this issue on macOS and performed several controlled experiments that revealed an additional behavior potentially relevant to the investigation: the failure depends on the Python Environments extension's lifecycle, not just whether it is installed or enabled.
Environment
macOS, Apple Silicon (M1 Pro)
VS Code version: 1.146.0
Python Environments: 1.42.0
Python: 3.15.2 (Homebrew)
Shells tested: Bash and Zsh
Project directory: ~/Desktop/Test test/
Script: test.py, containing only print("This works")
Execution command: Python: Run Python File in Terminal
The script path is correctly identified during environment lookup, but the execution command contains literal double quotes inside a single-quoted argument.
Python subsequently fails with [Errno 2] No such file or directory.
2. Disabling Python Environments fixes execution
With Python Environments disabled and the main Python extension still enabled, the same command succeeds:
Therefore, the failure is reproducible with both a global Homebrew interpreter and a virtual environment, while both work when Python Environments is disabled.
3. Unexpected extension lifecycle behavior
I observed the following sequence:
Configuration
Result
Fresh VS Code launch, Python Environments enabled
Fails
Disable Python Environments and reload
Works
Re-enable Python Environments without fully quitting VS Code
Still works
Terminate existing terminals and execute in a fresh terminal
Still works
Completely quit and restart VS Code
Fails again
The particularly interesting observation is that re-enabling Python Environments does not immediately restore the failure.
During successful executions after re-enabling the extension, the Python Environments output still records [SYS_GET] environment lookups, but I did not observe a corresponding runInTerminal: executeCommand entry.
After a complete VS Code restart, the malformed runInTerminal: executeCommand entry returns alongside the execution failure.
This suggests that the execution path or handler selection may differ depending on extension initialization state. I have not verified the internal registration mechanism, so this remains a hypothesis.
4. Additional observations
The issue reproduces with both Bash and Zsh.
It reproduces with a minimal Python script, independent of project code.
Manual execution from the integrated terminal works.
A directory without spaces works.
The Python extension's debug output includes Attempting to run Python file undefined, although I have not established whether that is relevant.
Potential investigation angle: The difference between a fresh extension-host initialization and disabling/re-enabling Python Environments may help identify how the runInTerminal execution path is selected.
I hope these observations are useful when validating the proposed fixes, particularly the extension lifecycle behavior.
The Python Environments output records a [SYS_GET] environment lookup but does not show a corresponding runInTerminal: executeCommand entry.
This differs from the failing behavior observed with version 1.42.0, where the malformed command was explicitly logged by runInTerminal.
Important limitation: Although execution succeeds with the pre-release installed and enabled, I have not confirmed whether terminal execution is being handled by Python Environments or by the main Python extension.
Therefore, this result demonstrates successful execution in the newer configuration, but does not independently establish that the quoting defect has been fixed inside Python Environments.
can't open file '/Volumes/BckUp3/.../VSC Test/"/Volumes/BckUp3/.../VSC Test/hello.py"': [Errno 2] No such file or directory
Tests and results:
Test | Result
-- | --
Run Python File | Failed
Run Python File in Dedicated Terminal | Failed
Run as Task | Passed
Manual execution (python hello.py) | Passed
Disable Python Environments extension and restart VS Code | Passed
Run with original Conda interpreter after restart | Passed
Re-enable/update to Python Environments v1.45.2026111601 | Failed again
Workaround confirmation:
Disabling the Python Environments extension and restarting VS Code resolved the issue without changing the Python script, its location, or the Conda environment.
After restarting, the script executed successfully using the original interpreter:
The issue reproduces with both tested Python Environments extension versions (v1.42.0 and v1.45.2026111601). Disabling the extension remains an effective workaround in this configuration.
Hope these additional reproduction details help with debugging and regression testing.
Hello,
We are aware of the issue which should be fixed by #26276. We will continue to do additional manual testing to ensure it is effectively fixed. Thanks for all the additional details
Activity
akoronn commentedon Nov 9, 2026
Bug: "Run Python File" passes literal quotation marks in the script path on Windows PowerShell
Description
When using the Run Python File command in VS Code, extra double quotation marks are included in the script path passed to Python.
As a result, Python cannot locate the script and exits with an
Invalid argumenterror.This issue started occurring after a recent VS Code update. The same workflow worked correctly before the update.
Steps to Reproduce
Actual Behavior
VS Code generates the following command:
Notice that the script path contains an additional pair of double quotation marks inside the single-quoted PowerShell argument.
Python interprets these double quotation marks as part of the filename and fails to open the script.
Error message:
Expected Behavior
The command should pass the script path without the extra literal double quotation marks:
The script should execute normally.
Additional Information
This suggests that the issue is related to command generation or argument quoting in the Python extension's terminal execution path.
Environment
Operating System
VS Code
Python
.venv\Scripts\python.exeExtensions
ms-python.python): 2026.10.0ms-python.debugpy): 2026.7.13061010ms-python.vscode-python-envs): 1.43.2026110501ms-python.vscode-pylance): 2026.4.1MKuula commentedon Nov 10, 2026
I'm not sure about this but perhaps the last update flipped the 'Use Environments Extension' toggle on? There is a mention in the Python settings that the default value changed.
Flipping this off fixes the problem temporarily until the real fix comes. Or using the debugger.
BeniNobel commentedon Nov 10, 2026
Thanks to everyone who reproduced this. A Windows report shows the same literal quotes in the script path, so this affects both PowerShell and Zsh.
I looked into the timing. The Python extension has passed a pre-quoted script path to Python Environments since #25405. Python Environments #1946 later changed terminal execution to quote arguments for Zsh and PowerShell. Together, those changes appear to produce the literal quotes in these reports.
That later change shipped in Python Environments 1.42.0 on November 4, the same evening my installation updated. This strongly suggests the update exposed the mismatch.
PR #26275 addresses it by passing the script path without added quotes.
fung19942003 commentedon Nov 12, 2026
I have a similar issue on Windows with Git Bash as the VS Code
default terminal.
When I click “Run Python File”, the script path is passed with
double quotes inside single quotes:
python.exe '"C:/path with spaces/script.py"'
Python then reports: [Errno 22] Invalid argument.
Running the same file manually with correctly quoted paths works.
Ctrl+F5 with Python Debugger also works.
Shell: Git Bash
Python: 3.14
Vscode version : 1.145.2 (c4453f8ea430795f941c1b2ff6c9321135a74a02)
edvilme commentedon Nov 13, 2026
Related: microsoft/vscode-python-environments#2026
edvilme commentedon Nov 13, 2026
Hello, we are actively looking at this issue and reviewing the proposed PR for a fix
BeniNobel commentedon Nov 14, 2026
Thanks for looking into this. #26275 and #26276 both address the quoting issue in
executeUsingExtension, so I wanted to flag the overlap.#26275 includes regression coverage for all three Run Python File commands, including the top-right icon, across several path cases. I also verified the patched extension inside VS Code on macOS. That check does not establish PowerShell behavior, but the test coverage may be useful when finalizing the fix.
Roadscript commentedon Nov 16, 2026
I reproduced this issue on macOS and performed several controlled experiments that revealed an additional behavior potentially relevant to the investigation: the failure depends on the Python Environments extension's lifecycle, not just whether it is installed or enabled.
Environment
~/Desktop/Test test/test.py, containing onlyprint("This works")VS Code Environment
Relevant extensions:
ms-python.vscode-python-envs): 1.42.0ms-python.python): Version not yet recordedAll experiments were performed using VS Code 1.146.0 on macOS arm64.
1. Reproduction with Python Environments enabled
With Python Environments enabled after a fresh VS Code launch, execution fails.
The Python Environments output contains:
The script path is correctly identified during environment lookup, but the execution command contains literal double quotes inside a single-quoted argument.
Python subsequently fails with
[Errno 2] No such file or directory.2. Disabling Python Environments fixes execution
With Python Environments disabled and the main Python extension still enabled, the same command succeeds:
/opt/homebrew/bin/python3 "/Users/kevenli/Desktop/Test test/test.py"Output:
I also tested a virtual environment located inside the same directory containing spaces:
This succeeds as well.
Therefore, the failure is reproducible with both a global Homebrew interpreter and a virtual environment, while both work when Python Environments is disabled.
3. Unexpected extension lifecycle behavior
I observed the following sequence:
The particularly interesting observation is that re-enabling Python Environments does not immediately restore the failure.
During successful executions after re-enabling the extension, the Python Environments output still records
[SYS_GET]environment lookups, but I did not observe a correspondingrunInTerminal: executeCommandentry.After a complete VS Code restart, the malformed
runInTerminal: executeCommandentry returns alongside the execution failure.This suggests that the execution path or handler selection may differ depending on extension initialization state. I have not verified the internal registration mechanism, so this remains a hypothesis.
4. Additional observations
Attempting to run Python file undefined, although I have not established whether that is relevant.Potential investigation angle: The difference between a fresh extension-host initialization and disabling/re-enabling Python Environments may help identify how the
runInTerminalexecution path is selected.I hope these observations are useful when validating the proposed fixes, particularly the extension lifecycle behavior.
Roadscript commentedon Nov 16, 2026
Follow-up: Python Environments 1.45.2026111301 (Pre-release)
After completing the investigation with Python Environments 1.42.0, I switched to the pre-release version 1.45.2026111301 and restarted VS Code.
Using the same project directory containing spaces (
~/Desktop/Test test/), the Python script now executes successfully.Generated command:
Output:
The Python Environments output records a
[SYS_GET]environment lookup but does not show a correspondingrunInTerminal: executeCommandentry.This differs from the failing behavior observed with version 1.42.0, where the malformed command was explicitly logged by
runInTerminal.Important limitation: Although execution succeeds with the pre-release installed and enabled, I have not confirmed whether terminal execution is being handled by Python Environments or by the main Python extension.
Therefore, this result demonstrates successful execution in the newer configuration, but does not independently establish that the quoting defect has been fixed inside Python Environments.
mcfunthomas commentedon Nov 16, 2026
Confirmed reproduction on macOS — Conda environment
I encountered the same issue on 16 November 2026 while running a simple Python script in VS Code.
Environment:
OS: macOS (Apple Silicon)
Shell: Zsh
Python: 3.11.14
Environment manager: Miniconda
Conda environment:
od_zera_do_aiPython Environments extension: v1.42.0 and v1.45.2026111601 (both tested)
Project stored on an external volume, with spaces in the directory path
Observed behaviour:
Both
Run Python FileandRun Python File in Dedicated Terminalgenerated a command with incorrectly nested quotation marks:Resulting error:
Tests and results:
Test | Result -- | -- Run Python File | Failed Run Python File in Dedicated Terminal | Failed Run as Task | Passed Manual execution (python hello.py) | Passed Disable Python Environments extension and restart VS Code | Passed Run with original Conda interpreter after restart | Passed Re-enable/update to Python Environments v1.45.2026111601 | Failed againWorkaround confirmation:
Disabling the Python Environments extension and restarting VS Code resolved the issue without changing the Python script, its location, or the Conda environment.
After restarting, the script executed successfully using the original interpreter:
Conclusion:
The issue reproduces with both tested Python Environments extension versions (v1.42.0 and v1.45.2026111601). Disabling the extension remains an effective workaround in this configuration.
Hope these additional reproduction details help with debugging and regression testing.
fix: do not pass redundant quotes to script path in executeUsingExten…
edvilme commentedon Nov 16, 2026
Hello,
We are aware of the issue which should be fixed by #26276. We will continue to do additional manual testing to ensure it is effectively fixed. Thanks for all the additional details
Fix Run Python File paths with spaces when using Python Environments (#…