1

我正在切换工具链,从基于 eclipse 的 python ide 切换到基于 vim 的等效工具链。

我目前正在尝试使用 pudb。

我正在尝试逐步完成谷歌提供的一些代码作为 tensorflow 的示例。它在 python3.5 上的 venv 中运行。没有一个调试器在导入 venv 特定库时出现问题,所以我相信它们都在预期的 venv 中运行。

pdb 和 ipdb 都完整地运行/单步执行代码,没有任何问题——这很棒。

当我尝试运行 pudb 时,出现以下错误:

Traceback (most recent call last): 
File "~/interpreters/p35/lib/python3.5/site-packages/tensorflow/python/platform/app.py",
line 44, in run
_sys.exit(main(_sys.argv[:1] + flags_passthrough)) TypeError: main() takes 0 positional arguments but 1 was given

主要定义如下:

def main(argv=None):  # pylint: disable=unused-argument    
   cifar10.maybe_download_and_extract()      
   if tf.gfile.Exists(FLAGS.train_dir):
     tf.gfile.DeleteRecursively(FLAGS.train_dir)
     tf.gfile.MakeDirs(FLAGS.train_dir)   
     train()


if __name__ == '__main__':   tf.app.run()

tf.app.run() 看起来像这样:

def run(main=None, argv=None):
   #Runs the program with an optional 'main' function and 'argv' list.
   f = flags.FLAGS
   # Extract the args from the optional `argv` list.
   args = argv[1:] if argv else None
   # Parse the known flags from that list, or from the command line otherwise.
   # pylint: disable=protected-access
   flags_passthrough = f._parse_flags(args=args)
   # pylint: enable=protected-access
   main = main or _sys.modules['__main__'].main
   # Call the main function, passing through any arguments to the final program.
   _sys.exit(main(_sys.argv[:1] + flags_passthrough))

我真的很希望让 pudb 处理这段代码,因为我真的很喜欢它的界面。

我在这里有很多选择,但很快就用完了。有人对 pdb、ipdb 和 pudb 之间的操作差异有任何想法吗?

谢谢,

nt

4

0 回答 0