Exeleration-G
Exeleration-G

Reputation: 1470

How can I display exceptions normally in iPython?

I like iPythons way of mixing terminal commands and Python, but I dislike its way of showing exceptions. It looks like this:

>>> import foo
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-5-34d390fb3acc> in <module>()
----> 1 import foo

ImportError: No module named foo

I would rather see the normal Python exception printing:

>>> import foo
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named foo

I've searched for such a setting in the config but couldn't find it. How can I do it?

Upvotes: 3

Views: 103

Answers (1)

vaultah
vaultah

Reputation: 46523

Set xmode to plain:

In [8]: %xmode plain
Exception reporting mode: Plain

In [9]: import foo
Traceback (most recent call last):
  File "<ipython-input-9-34d390fb3acc>", line 1, in <module>
    import foo
ImportError: No module named 'foo'

Or use the corresponding config file entry:

c.TerminalInteractiveShell.xmode = 'Plain'

Upvotes: 6

Related Questions