Skip to content

Wrong path when running .py script in WSL #24407

@Santiq22

Description

@Santiq22

Type: Bug

There is a problem at the time of running a Python script using VS Code connected to WSL. If I save the Python script called 'test' as 'test', and then I run the script inside VS Code selecting a conda environment installed on WSL, it will run correctly. But if I save the script as 'test.py', explicitly indicating that it is a Python file, when I run it on VS Code, the terminal will throw "[Errno 2] No such file or directory". This is because the filepath VS Code builds to run the script involves the ' : ' (colon character) in the 'c' folder (disk C of windows). It shoudln't happen beacause WSL interprets the disk C as 'c' not as 'c:', driving to an incorrect path at script run time. Is there a way out of this problem? Or is it a bug that must be fixed?

VS Code version: Code 1.95.2 (e8653663e8840adaf45af01eab5c627a5af81807, 2024-11-07T11:07:22.054Z)
OS version: Windows_NT x64 10.0.19045
Modes:
Remote OS version: Linux x64 5.15.153.1-microsoft-standard-WSL2

Extensions (16)
Extension Author (truncated) Version
vsc-python-indent Kev 1.18.0
jupyter-keymap ms- 1.1.2
remote-wsl ms- 0.88.5
jinja who 0.0.8
python-environment-manager don 1.2.4
linter-gfortran for 3.2.0
debugpy ms- 2024.12.0
python ms- 2024.18.0
vscode-pylance ms- 2024.11.1
jupyter ms- 2024.10.0
jupyter-keymap ms- 1.1.2
jupyter-renderers ms- 1.0.21
vscode-jupyter-cell-tags ms- 0.1.9
vscode-jupyter-slideshow ms- 0.1.6
cpptools ms- 1.22.11
autodocstring njp 0.6.1
A/B Experiments
vsliv368cf:30146710
vspor879:30202332
vspor708:30202333
vspor363:30204092
vscod805cf:30301675
binariesv615:30325510
vsaa593:30376534
py29gd2263:31024239
c4g48928:30535728
azure-dev_surveyone:30548225
a9j8j154:30646983
962ge761:30959799
pythongtdpath:30769146
pythonnoceb:30805159
asynctok:30898717
pythonmypyd1:30879173
2e7ec940:31000449
pythontbext0:30879054
cppperfnew:31000557
dsvsc020:30976470
pythonait:31006305
dsvsc021:30996838
f3je6385:31013174
dvdeprecation:31068756
dwnewjupytercf:31046870
2f103344:31071589
impr_priority:31102340
nativerepl2:31139839
refactort:31108082
pythonrstrctxt:31112756
cf971741:31144450
iacca1:31171482
notype1:31157159
5fd0e150:31155592
dwcopilot:31170013

Metadata

Metadata

Assignees

Labels

bugIssue identified by VS Code Team member as probable bugtriage-neededNeeds assignment to the proper sub-team

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions