VSCode 调试器 FileNotFoundError

VSCode Debugger FileNotFoundError

我目前有一些 .py 和 .ipynb 文件存储在 Google 驱动器 (G:) 上,以便在我的设备上访问。将 .ipynb 文件转换为 .py 然后 运行 VSCode 中的调试器时,我有时会遇到以下问题:

Microsoft Windows [Version 10.0.19043.1052]
(c) Microsoft Corporation. All rights reserved.

G:\My Drive\Code & Programming>C:/Users/Admin/Anaconda3/Scripts/activate

(base) G:\My Drive\Code & Programming>conda activate base

(base) G:\My Drive\Code & Programming> cmd /C "C:\Users\Admin\Anaconda3\python.exe c:\Users\Admin\.vscode\extensions\ms-python.python-2021.5.926500501\pythonFiles\lib\python\debugpy\launcher 58376 -- "g:\My Drive\<dir1>\test.py" "
pydev debugger: critical: unable to get real case for file. Details:
filename: g:\
drive: G:\
parts: ['']
(please create a ticket in the tracker to address this).
Traceback (most recent call last):
  File "c:\Users\Admin\.vscode\extensions\ms-python.python-2021.5.926500501\pythonFiles\lib\python\debugpy\_vendored\pydevd\pydevd_file_utils.py", line 221, in _get_path_with_real_case
    return _resolve_listing(drive, iter(parts))
  File "c:\Users\Admin\.vscode\extensions\ms-python.python-2021.5.926500501\pythonFiles\lib\python\debugpy\_vendored\pydevd\pydevd_file_utils.py", line 192, in _resolve_listing    
    raise FileNotFoundError('Unable to find: %s in %s' % (
FileNotFoundError: Unable to find:  in G:\

During handling of the above exception, another exception occurred:

但是,如果我将 .py 文件保存到不同的 G:\ 目录,调试器运行:

Microsoft Windows [Version 10.0.19043.1052]
(c) Microsoft Corporation. All rights reserved.

G:\My Drive\Code & Programming>C:/Users/Admin/Anaconda3/Scripts/activate

(base) G:\My Drive\Code & Programming>conda activate base

(base) G:\My Drive\Code & Programming> cmd /C "C:\Users\Admin\Anaconda3\python.exe c:\Users\Admin\.vscode\extensions\ms-python.python-2021.5.926500501\pythonFiles\lib\python\debugpy\launcher 53852 -- "g:\My Drive\<dir2>\test.py" "

该错误似乎并没有真正提供太多信息,说明为什么 dir1 中的 test.py 文件失败但 dir2 中的文件失败。

谢谢!

Visual Studio,连同其他广泛使用的 IDE,读取大量目录位置作为命令行命令。

因此,删除命令行中使用的特殊字符很重要(例如用于标志的 -,或分隔命令的 )。

正如您在评论回复中所述,删除其中一个目录的空格解决了该问题。

没有全面的指南,因为它是 IDE/system 系统基础,但 This Winodws Guide 应该是一个好的开始。

祝一切顺利!