[英]Script works when run through normal python interpreter but fails when run through jupyter
I'm using VSCode messing around with jupyter (writing in python 3.9.7) I have two questions here:我正在使用 VSCode 和 jupyter(用 python 3.9.7 编写)我在这里有两个问题:
First question, I have a script that I've written as a .py file and want to run it through jupyter so I can use its variable viewer (I hate the cluttered and messy way vscode's built-in variable viewer works), it works when I run it normally without jupyter, (using f5/ ctrl+f5, etc) but when I try to run it with jupyter, for some reason it appears to ignore the sys import and path editing to enable the call on another script.第一个问题,我有一个脚本,我已将其编写为 .py 文件并希望通过 jupyter 运行它,以便我可以使用它的变量查看器(我讨厌 vscode 的内置变量查看器的工作方式杂乱无章),它有效当我在没有 jupyter 的情况下正常运行它时(使用 f5/ctrl+f5 等)但是当我尝试使用 jupyter 运行它时,出于某种原因,它似乎忽略了 sys 导入和路径编辑以启用对另一个脚本的调用。
Why would this be happening and how can I fix it?为什么会发生这种情况,我该如何解决?
Secondly, how do you enter debugging mode through jupyter?其次,如何通过jupyter进入调试模式? I've found that you can right click then hit "Run current file in interactive window" and its other run options to launch the script with jupyter, but there doesn't seem to be a way to enter line-by-line debugging.我发现您可以右键单击然后点击“在交互式窗口中运行当前文件”及其其他运行选项以使用 jupyter 启动脚本,但似乎没有办法进入逐行调试。 How do I get into debugging??我如何进入调试?
I think the differences of cwd
caused it.我认为cwd
的差异导致了它。 Can you try to append the path with the absolute path?您可以尝试使用绝对路径附加路径吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.