Skip to content

Unable to "Run Python file in terminal" on paths with parenthesis #20360

@luqas11

Description

@luqas11

Type: Bug

Behaviour

Expected vs. Actual

Expected: when executing command "Run Python file in terminal" from command palette, the Python file runs, with any characters on it's path.

Actual: when executing command "Run Python file in terminal" from command palette, the Python file throws an error if it has parenthesis present on it's path.

Steps to reproduce:

  1. Create a folder with parenthesis on it's name.
  2. Create a .py file inside that folder.
  3. Try to run the file using "Run Python file in terminal" from VSCode command palette.

Example:

WIth the next folder structure:
/Example
----/some_folder
--------/test.py
----/some_folder(b)
--------/test.py

The same file test.py runs ok under directory some_folder, but throws the following error under folder some_folder(b):

PS C:\Example> & C:/path-to-python/python3.10.exe c:/Example/some_folder(b)/test.py
b : The term 'b'  is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line: 1 char: 92
+ ... Microsoft/WindowsApps/python3.10.exe c:/Example/some_folder(b)/test.p ...      
+                                                                 ~
    + CategoryInfo          : ObjectNotFound: (b:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

If I run C:/path-to-python/python3.10.exe 'c:/Example/some_folder(b)/test.py' in my terminal, the file runs ok. A possible solution to this problem could be using quotes on the file path when the extension runs that command.

Diagnostic data

  • Python version (& distribution if applicable, e.g. Anaconda): 3.10.9
  • Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): MicrosoftStore
  • Value of the python.languageServer setting: Default
Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

XXX

User Settings


languageServer: "Pylance"

Extension version: 2022.20.0
VS Code version: Code 1.74.0 (5235c6bb189b60b01b1f49062f4ffa42384f8c91, 2022-12-05T16:38:16.075Z)
OS version: Windows_NT x64 10.0.19044
Modes:
Sandboxed: No

System Info
Item Value
CPUs Intel(R) Core(TM) i5-7600K CPU @ 3.80GHz (4 x 3792)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_renderer: enabled_on
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: disabled_off
Load (avg) undefined
Memory (System) 15.96GB (9.69GB free)
Process Argv C:\Example --crash-reporter-id 8ec72535-aa21-4c09-bef6-4e907fb1eeb4
Screen Reader no
VM 0%
A/B Experiments
vsliv368:30146709
vsreu685:30147344
python383cf:30185419
vspor879:30202332
vspor708:30202333
vspor363:30204092
vswsl492:30256859
vslsvsres303:30308271
pythonvspyl392:30443607
vserr242cf:30382550
pythontb:30283811
vsjup518:30340749
pythonptprofiler:30281270
vshan820:30294714
vstes263cf:30335440
vscorecescf:30445987
pythondataviewer:30285071
vscod805:30301674
binariesv615:30325510
bridge0708:30335490
bridge0723:30353136
cmake_vspar411:30581797
vsaa593:30376534
pythonvs932:30410667
cppdebug:30492333
vsclangdc:30486549
c4g48928:30535728
dsvsc012cf:30540253
azure-dev_surveyone:30548225
vscccc:30610679
pyindex848:30577860
nodejswelcome1:30587005
2e4cg342:30602488
gswce1:30612156
3d0df643:30613357
dbltrim-noruby:30604474
89544117:30613380
fim-prod:30623723

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-terminalbugIssue identified by VS Code Team member as probable buggood first issueneeds PRReady to be worked onverifiedVerification succeeded

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions