Pshemy108
Pshemy108

Reputation: 323

"Name Error: name 'get_ipython' is not defined" while preparing a debugging session via "import ipdb"

I'm trying to install and use ipdb (IPython-enabled pdb) on Python 3.3.5 32 bit on Win10 using PIP 8.1.2. I've installed via PIP (had to install it seprately) in windows cmd with no errors:

 pip install ipdb

I wrote a simple test script expecting to stop in debugger before printing 'test' string, ipdb_test.py:

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

When running it from IDLE editor the following exceptions show up:

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'

Upvotes: 0

Views: 5140

Answers (1)

Pshemy108
Pshemy108

Reputation: 323

As the issue seemed to be related to IPython, I've checked that the version installed while resolving ipdb dependencies was: "ipython-5.1.0".

The WA solution for the issue occured to be a fallback to version 4.2.1 of IPython:

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

After that ipdb halted on a breakpoint as expected:

$ 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>

It may be a valid case to contact the IPython project team on the issue, meanwhile I find an initial task of running a debug session completed.

Upvotes: 2

Related Questions