python - PUDB 错误:
问题描述
我是pudb的新手。它在大多数情况下运行良好,但是当我尝试进入一个它显然无法识别的库时,我收到以下消息:
<no source code available>
If this is generated code and you would like the source code to show up here,
add it to linecache.cache, like
import linecache
linecache.cache[filename] = (size, mtime, lines, fullname)
You can also set the attribute _MODULE_SOURCE_CODE in the module in which this function
was compiled to a string containing the code.
我试过导入'linecache','cache'属性是一个字典。我曾尝试为缺少的模块创建一个条目几次,但均未成功。
有人可以举一个更简单和/或实用的方法将无法识别的模块添加到 pudb 的示例吗?
解决方案
它对我有用的方式如下。
当执行一段即时生成的代码时,我收到了这条消息。我追踪了生成代码的位置,并添加了:
import linecache
linecache.cache[__file__] = (len(source), 0, source, __file__)
(其中source
变量对应于生成的源)
之后我观察到,在pudb
交互模式下,堆栈列表中出现了一个新项目。这个新项目在抛出<no source code available>
消息的那个之前。
当我浏览这个新项目时,我可以看到生成的源代码。
推荐阅读
- javascript - 是否可以运行 google app 脚本将 html 表单从网站提交到移动浏览器上的 google sheet?
- node.js - 如何使用 Node.js 中的 youtube api 通过 Web 应用程序(如 Whatsapp)中的给定链接播放 youtube 视频?
- angular - 拦截器内部未定义单例服务
- javascript - 在 vue.js 中,如何在 functions.js 中使用 i18n?
- vector - 如何从自定义点而不是四元数的 (0, 0, 0) 开始创建 Vector3
- reactjs - 使用带有反应的 ramda 管道
- powershell - vbs 包装的 ps1 脚本提供不完整的结果
- c# - 为什么我的组合框为空?即使不是空的
- python - 如何使用选项菜单选择函数的输入
- function - Geosparql 函数