"Name Error: name 'get_ipython' is not defined" while preparing a debugging session via "import ipdb"
"Name Error: name 'get_ipython' is not defined" while preparing a debugging session via "import ipdb"
我正在尝试使用 PIP 8.1.2 在 Win10 上的 Python 3.3.5 32 位上安装和使用 ipdb(IPython-enabled pdb)。
我已经在 windows cmd 中通过 PIP(必须单独安装)安装,没有错误:
pip install ipdb
我写了一个简单的测试脚本,希望在打印 'test' 字符串之前在调试器中停止,ipdb_test.py:
import ipdb
ipdb.set_trace()
print('test')
当运行它从 IDLE 编辑器中出现时,会出现以下异常:
Traceback (most recent call last):
File "C:\Python33.5-32\lib\site-packages\ipdb\__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-32\lib\site-packages\ipdb\__init__.py", line 7, in <module>
from ipdb.__main__ import set_trace, post_mortem, pm, run # noqa
File "C:\Python33.5-32\lib\site-packages\ipdb\__main__.py", line 51, in <module>
(...)
File "C:\Python33.5-32\lib\site-packages\prompt_toolkit\terminal\win32_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:\temp\ipdb_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:\temp\ipdb_test.py(3)<module>()
1 import ipdb
2 ipdb.set_trace()
----> 3 print('test')
ipdb>
就此问题联系 IPython 项目团队可能是一个有效的案例,同时我发现 运行 已完成调试会话的初始任务。
我正在尝试使用 PIP 8.1.2 在 Win10 上的 Python 3.3.5 32 位上安装和使用 ipdb(IPython-enabled pdb)。 我已经在 windows cmd 中通过 PIP(必须单独安装)安装,没有错误:
pip install ipdb
我写了一个简单的测试脚本,希望在打印 'test' 字符串之前在调试器中停止,ipdb_test.py:
import ipdb
ipdb.set_trace()
print('test')
当运行它从 IDLE 编辑器中出现时,会出现以下异常:
Traceback (most recent call last):
File "C:\Python33.5-32\lib\site-packages\ipdb\__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-32\lib\site-packages\ipdb\__init__.py", line 7, in <module>
from ipdb.__main__ import set_trace, post_mortem, pm, run # noqa
File "C:\Python33.5-32\lib\site-packages\ipdb\__main__.py", line 51, in <module>
(...)
File "C:\Python33.5-32\lib\site-packages\prompt_toolkit\terminal\win32_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:\temp\ipdb_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:\temp\ipdb_test.py(3)<module>()
1 import ipdb
2 ipdb.set_trace()
----> 3 print('test')
ipdb>
就此问题联系 IPython 项目团队可能是一个有效的案例,同时我发现 运行 已完成调试会话的初始任务。