Skip to content

Run Python File generates incorrectly quoted script paths on macOS zsh when directory contains spaces #1995

Open
microsoft/vscode-python
#26279

Description

@acetone0

Description

When using the "Run Python File" command in VS Code on macOS with zsh as the default shell, the generated terminal command contains incorrectly nested quotation marks if the Python script is located in a directory whose path contains spaces.

Specifically, the script path is enclosed in single quotes, but additional double quotes are included inside them. As a result, Python interprets these double quotes as literal characters in the filename, causing a file-not-found error.

Environment

  • Operating System: macOS
  • Shell: zsh
  • Python extension: 2026.10.0
  • Python Environments extension: 1.42.0
  • Python interpreter: Project virtual environment (.venv)

Steps to Reproduce

  1. Create a Python project in a directory containing spaces.
  2. Select the project's virtual environment as the Python interpreter.
  3. Create a Python script (e.g., test.py).
  4. Click "Run Python File" in the upper-right corner of the editor.

Actual Behavior

VS Code generates a command with incorrectly nested quotation marks around the script path:

'/path with spaces/.venv/bin/python' '"/path with spaces/test.py"'

The additional double quotes are interpreted as literal characters in the filename, causing Python to fail to locate the script.

Expected Behavior

The command should be generated with correctly quoted paths:

'/path with spaces/.venv/bin/python' '/path with spaces/test.py'

Additional Tests

The following tests were performed:

  • The selected Python interpreter works correctly.
  • The reported working directory and script location are correct.
  • Manually executing the correctly quoted command works successfully.
  • Moving the same Python script to a directory without spaces resolves the issue.
  • Disabling python.terminal.shellIntegration.enabled does not resolve the issue.
  • Disabling Python environment terminal auto-activation does not resolve the issue.

The issue appears to be related to command generation or path quoting when using zsh and directory paths containing spaces.

Could you please investigate this issue?

Activity

  1. leo2kappa commented on Nov 6, 2026

    @leo2kappa

    Confirming on macOS 27.0.1, VS Code 1.145.2, Python Environments 1.42.0,
    Python extension 2026.10.0 (also 2026.8.0). Same command:
    python3 '"/path with spaces/script.py"'. It happens with both zsh and bash.
    Disabling the Python Environments extension and reloading the window makes
    Run Python File work again, so this is a workaround until it is fixed.

  2. xavier862 commented on Nov 6, 2026

    @xavier862

    Exact same symptoms here on macOS Tahoe 26.6.2 as well as Sequoia 15.8.1, VS Code 1.145.0 or 1.145.2, Python Environments 1.42.0, zsh:
    python3 '"/path with spaces/script.py"'.
    Disabling Python Environments and restarting the extensions fixed the problem.

  3. Ary0xploits commented on Nov 8, 2026

    @Ary0xploits

    Faced the same issue. Even a simple print("Hello world") would give error. As a temporary fix, I disabled Python environments and it works fine now.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions