简体   繁体   English

脚本在通过普通 python 解释器运行时工作,但在通过 jupyter 运行时失败

[英]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.

相关问题 我的机器人流程自动化脚本在通过本地 Jenkins 执行时失败,但在通过控制台运行时工作正常 - My robot process automation script fails when executed through local Jenkins but works fine when run through console Python脚本单独工作,但通过nodejs子进程运行时没有这样的文件 - Python script works alone but no such file when run through nodejs child process 可可应用无法开始循环python脚本。 通过xcode构建/运行时有效 - Cocoa app cannot start looping python script. Works when built/run through xcode Python Twitter bot是从解释器工作但不是作为程序运行时? - Python Twitter bot works from interpreter but not when run as program? 使用文件时,Python脚本无法通过php运行 - Python script won't run through php when using files 通过anaconda提示符执行python代码时,导入numpy起作用,但通过cmd运行时产生错误 - Import numpy works when python code executed through anaconda prompt but produces an error when run through cmd 通过PHP运行时无法从python脚本获取输出 - Not getting output from python script when run through PHP 当脚本通过python运行时如何捕获bash错误 - How to catch a bash error when the script is run through python 通过Windows运行时,Python脚本突然退出 - Python script suddenly exiting when being run through windows 通过任务计划程序运行时,Python脚本未创建文件 - Python Script not creating file when run through Task Scheduler
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM