Skip to content

Run Python File passes literal quotes in script path to terminal #26274

Agent suggestions

Public preview

Description

Description

Behaviour

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

  1. Install and enable the Python and Python Environments extensions.
  2. Open a Python file inside a directory with spaces in its path.
  3. Click the top-right Run Python File button.
  4. 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
  • OS: macOS
  • Terminal shell: zsh

Issue Details

Item Value
Issue Category Bug
Target Python
Repository Microsoft/vscode-python
VS Code Version Code 1.145.0 (Universal) (a717861c07586a53d83b80d742cd3f59b20a6273, 2026-11-03T15:03:51-08:00)
OS Version Darwin arm64 25.6.0
Extension Identifier ms-python.python
Extension Version 2026.10.0
Extension Publisher ms-python

Activity

  1. akoronn commented on Nov 9, 2026

    @akoronn

    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 argument error.

    This issue started occurring after a recent VS Code update. The same workflow worked correctly before the update.

    Steps to Reproduce

    1. Open a Python project in VS Code.
    2. Use a project directory whose path contains spaces and non-ASCII characters (Japanese characters in my case).
    3. Create and activate a virtual environment.
    4. Open a Python file.
    5. Click Run Python File.

    Actual Behavior

    VS Code generates the following command:

    & '<project-path>\.venv\Scripts\python.exe' '"<project-path>/gui.py"'

    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:

    python.exe: can't open file '<project-path>\"<project-path>\gui.py"': [Errno 22] Invalid argument
    

    Expected Behavior

    The command should pass the script path without the extra literal double quotation marks:

    & '<project-path>\.venv\Scripts\python.exe' '<project-path>/gui.py'

    The script should execute normally.

    Additional Information

    • The issue occurs only when using Run Python File.
    • Running the same script through the VS Code debugger (F5) works correctly.
    • Running the script manually with a correctly quoted command also works.
    • The virtual environment is activated successfully.
    • The project path contains both spaces and Japanese characters.
    • This issue did not occur before a recent VS Code update.

    This suggests that the issue is related to command generation or argument quoting in the Python extension's terminal execution path.

    Environment

    Operating System

    • Windows 11
    • Windows_NT x64 10.0.26300
    • PowerShell

    VS Code

    • Version: 1.145.2 (User Setup)
    • Commit: c4453f8ea430795f941c1b2ff6c9321135a74a02
    • Date: 2026-11-06T04:28:13Z
    • Electron: 43.8.3
    • Chromium: 150.0.7871.250
    • Node.js: 24.22.1
    • V8: 15.0.245.31-electron.0

    Python

    • Version: 3.14.8
    • Interpreter: .venv\Scripts\python.exe

    Extensions

    • Python (ms-python.python): 2026.10.0
    • Python Debugger (ms-python.debugpy): 2026.7.13061010
    • Python Environments (ms-python.vscode-python-envs): 1.43.2026110501
    • Pylance (ms-python.vscode-pylance): 2026.4.1
  2. MKuula commented on Nov 10, 2026

    @MKuula

    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.

  3. BeniNobel commented on Nov 10, 2026

    @BeniNobel
    Author

    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.

  4. fung19942003 commented on Nov 12, 2026

    @fung19942003

    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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions