python - VSCode 调试器 FileNotFoundError
问题描述
我目前有一些 .py 和 .ipynb 文件存储在 Google Drive (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 一起,将许多目录位置作为命令行命令读取。
出于这个原因,删除命令行中使用的特殊字符(例如-
用于标志或
分隔命令的 s)非常重要。
正如您在回复评论中所述,删除其中一个目录的空格解决了该问题。
没有全面的指南,因为它是基于系统的 IDE/系统,但是这个 Winodws 指南应该是一个好的开始。
祝一切顺利!
推荐阅读
- c#-4.0 - ActiveX 对象的“Created”属性始终为 false
- c# - 未捕获的类型错误:无法在 Chrome 中读取 null 的属性“样式”
- autocomplete - Robot Frameworkride.py 工具,如何实现文本框自动完成
- python-3.x - 插入数据时出错:cx_Oracle.DatabaseError: ORA-01722: invalid number
- istio - 如何在 kubernetes 中为 Istio 负载均衡器创建自定义错误页面
- google-apps-script - 如何将范围定义为“选定字段”?
- php - PHP登录系统和会话失败
- .net - 具有组和未排序索引的列表视图 - 获取下一项
- wordpress - 在 WC_Order 中使用多个 id - Woocommerce
- wordpress - Wordpress 测试站点自动重定向到 HTTPS