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
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