通过"import ipdb"准备调试会话时"Name Error: name 'get_ipython' is not defined"



我试图在Win10上使用PIP 8.1.2在Python 3.3.5 32位上安装和使用ipdb (IPython-enabled pdb)。我已经通过PIP安装(必须单独安装)在windows cmd中没有错误:

 pip install ipdb

我写了一个简单的测试脚本,期望在打印'test'字符串之前停止调试器,ipdb_test.py:

import ipdb
ipdb.set_trace()
print('test')

从IDLE编辑器运行时,出现以下异常:

Traceback (most recent call last):
  File "C:Python33.5-32libsite-packagesipdb__main__.py", line 44, in <module>
    get_ipython
NameError: name 'get_ipython' is not defined
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "C:/temp/ipdb_test.py", line 1, in <module>
    import ipdb
  File "C:Python33.5-32libsite-packagesipdb__init__.py", line 7, in <module>
    from ipdb.__main__ import set_trace, post_mortem, pm, run             # noqa
  File "C:Python33.5-32libsite-packagesipdb__main__.py", line 51, in <module>
  (...)
  File "C:Python33.5-32libsite-packagesprompt_toolkitterminalwin32_output.py", line 266, in flush
    self.stdout.flush()
AttributeError: 'NoneType' object has no attribute 'flush'

由于问题似乎与IPython有关,我检查了在解决ipdb依赖关系时安装的版本是:" IPython -5.1.0"。

此问题的WA解决方案是退回到IPython 4.2.1版本:

pip install "ipython<5"
    (...)
    Successfully uninstalled ipython-5.1.0
    Successfully installed ipython-4.2.1

ipdb在预期的断点上停止后:

$ python C:tempipdb_test.py
WARNING: Readline services not available or not loaded.
WARNING: Proper color support under MS Windows requires the pyreadline library.
You can find it at:
http://ipython.org/pyreadline.html
Defaulting color scheme to 'NoColor'
> c:tempipdb_test.py(3)<module>()
      1 import ipdb
      2 ipdb.set_trace()
----> 3 print('test')
ipdb>

这可能是一个有效的情况下,联系IPython项目团队的问题,同时我发现一个初始任务运行调试会话完成。

相关内容

  • 没有找到相关文章

最新更新