microsoft / microsoft/vscode

It is not showing my .txt file when it is clearly in the same directory

Open
#332,610 0 comments 0 reactions 1 assignee Claimed by @anthonykim1 View on GitHub
Dominant language
TypeScript
Stars
193k
Forks
42.4k
PR merge metrics
PR metrics pending

Description

Image

Type: Bug

When running a Python file in VS Code on macOS, Python cannot find dio.txt even though it exists in the same directory as the script. os.getcwd() correctly returns /Users/harshitkumaryadav/Desktop/python_course/files, and ls -lb confirms dio.txt exists there, but os.path.exists("dio.txt") returns False and open("dio.txt", "r") raises FileNotFoundError. Running the script with python3 -u from VS Code produces the same issue.

VS Code version: Code 1.134.0 (Universal) (110a328ea54b42367b803ec53ee0bf52ef26b419, 2026-08-18T18:24:44Z)
OS version: Darwin arm64 25.6.0
Modes:

System Info

|Item|Value|
|---|---|
|CPUs|Apple M4 (10 x 2400)|
|GPU Status|2d_canvas: enabled
GPU0: VENDOR= 0x106b [Google Inc. (Apple)], DEVICE=0x0000 [ANGLE (Apple, ANGLE Metal Renderer: Apple M4, Version 26.6.2 (Build 25G83))], DRIVER_VENDOR=Apple, DRIVER_VERSION=26.6.2 *ACTIVE*
Machine model name: Mac
Machine model version: 16.12
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_graphite: enabled_on
trees_in_viz: disabled_off
video_decode: enabled
video_encode: enabled
webgl: enabled
webgpu: enabled
webnn: disabled_off|
|Load (avg)|2, 2, 2|
|Memory (System)|16.00GB (0.06GB free)|
|Process Argv|--crash-reporter-id 8e19612a-fc4e-4855-a527-2429ee81b265|
|Screen Reader|no|
|VM|0%|
Extensions (9)

Name|Identifier|Author|Version
---|---|---|---
Code Runner|formulahendry.code-runner|formulahendry|0.12.2
Python Debugger|ms-python.debugpy|ms-python|2026.6.0
Python|ms-python.python|ms-python|2026.4.0
Pylance|ms-python.vscode-pylance|ms-python|2026.3.1
Python Environments|ms-python.vscode-python-envs|ms-python|1.36.0
CMake Tools|ms-vscode.cmake-tools|ms-vscode|1.23.52
C/C++ DevTools|ms-vscode.cpp-devtools|ms-vscode|0.6.18
C/C++|ms-vscode.cpptools|ms-vscode|1.33.8
C/C++ Extension Pack|ms-vscode.cpptools-extension-pack|ms-vscode|1.5.1

A/B Experiments

```
vsliv368:30146709
vswsl492cf:30256860
pythonvspyt551:31249599
binariesv615:30325510
nativeloc1:31344060
dwcopilot:31170013
dwoutputs:31242946
copilot_t_ci:31333650
e5gg6876:31282496
pythonrdcb7:31342333
6518g693:31463988
aj953862:31281341
envsactivate1:31551504
gh487529:31544284
cloudbuttont:31379625
3efgi100_wstrepl:31403338
ec5jj548:31422691
cp_cls_t_966_ss:31526232
4je02754:31572277
c3h7c220:31478652
cp_cls_c_1081:31454833
conptydll_true:31498968
e9c30283:31461165
test_treatment2:31471001
46204921:31447328
ei9d7968:31496641
chat:31457767
8hig5102:31480529
89g7j272:31518289
i2gc6536:31499202
52612955:31516516
ddid_t:31478206
hmra_i5g22:31518061
bjc72774_agent_sandbox:31557830
7df3h592:31512476
cp_cls_t_1082:31535311
logging_enabled_new:31498466
j0d79568:31499440
jb_cp_cls_t_632:31543129
748c7209:31512887
32d76977:31512328
ha629193:31508444
jh5f2457_c:31540921
jbcp_cls_pctr_t:31531130
61138546:31518536
cp_intellij_t_nes:31548657
jf4hg949:31526829
ahp-both-windows:31556933
sessions_5:31532894
ihg5j128:31534457
f412h606:31551416
7g2b5551:31542111
sandbox-ui-on-2:31543161
nes-ex-cf-euporie-03:31542868
enable_editor_pane_layout:31569726
allow-none:31555437
fd5dc207:31551400
36h42362:31564511
c7c27ce7:31554789
1h923230:31564177
1532g621_copy:31554320
treatment-23-1:31555779
unuse_dynamic_mcp:31555281
0d8dfbc3:31570291
nemo-v2:31565334
0c1h4866:31566224
session-archive:31558132
5b8j3302:31564601
mangle-name-treatment:31572634
permission_prompt_control:1332567
ccr_pr_nudge_auto_review:1319472
vsc_wsm_c:1340633

```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.