[IPython-dev] IPython.ipapi stopped working

Ondrej Certik ondrej@certik...
Wed Oct 14 13:26:02 CDT 2009


Hi,

with the latest ipython bzr trunk:

$ bin/doctest
============================= test process starts ==============================
executable:   /usr/bin/python  (2.6.2-final-0)

Traceback (most recent call last):
  File "bin/doctest", line 30, in <module>
    "blacklist": blacklist})
  File "/home/ondrej/repos/sympy/sympy/utilities/runtests.py", line
140, in doctest
    dtest = t.test()
  File "/home/ondrej/repos/sympy/sympy/utilities/runtests.py", line 368, in test
    self.test_file(f)
  File "/home/ondrej/repos/sympy/sympy/utilities/runtests.py", line
382, in test_file
    setup_pprint()
  File "/home/ondrej/repos/sympy/sympy/utilities/runtests.py", line
48, in setup_pprint
    init_printing(sstrrepr)
  File "/home/ondrej/repos/sympy/sympy/interactive/__init__.py", line
14, in init_printing
    ip = IPython.ipapi.get()
AttributeError: 'module' object has no attribute 'ipapi'


That happens because there is no "ipapi" in IPython:

In [1]: import IPython.ipapi
------------------------------------------------------------
Traceback (most recent call last):
  File "<ipython console>", line 1, in <module>
ImportError: No module named ipapi


A quick experimentation shows that this could work:

In [1]: import IPython.core.ipapi

In [2]:

So applying this patch:

$ git diff
diff --git a/sympy/interactive/__init__.py b/sympy/interactive/__init__.py
index 5e253b8..d0cc9fe 100644
--- a/sympy/interactive/__init__.py
+++ b/sympy/interactive/__init__.py
@@ -11,7 +11,7 @@ def init_printing(stringify_func):
     try:
         import IPython

-        ip = IPython.ipapi.get()
+        ip = IPython.core.ipapi.get()

         if ip is not None:
             def result_display(self, arg):


moves us a bit further, but not enough:


$ bin/doctest
============================= test process starts ==============================
executable:   /usr/bin/python  (2.6.2-final-0)

Traceback (most recent call last):
  File "bin/doctest", line 30, in <module>
    "blacklist": blacklist})
  File "/home/ondrej/repos/sympy/sympy/utilities/runtests.py", line
140, in doctest
    dtest = t.test()
  File "/home/ondrej/repos/sympy/sympy/utilities/runtests.py", line 368, in test
    self.test_file(f)
  File "/home/ondrej/repos/sympy/sympy/utilities/runtests.py", line
382, in test_file
    setup_pprint()
  File "/home/ondrej/repos/sympy/sympy/utilities/runtests.py", line
48, in setup_pprint
    init_printing(sstrrepr)
  File "/home/ondrej/repos/sympy/sympy/interactive/__init__.py", line
14, in init_printing
    ip = IPython.core.ipapi.get()
  File "/home/ondrej/usr/lib/python/IPython/core/ipapi.py", line 31, in get
    most_recent = insts[0]
IndexError: list index out of range




Any ideas how to fix this? I can't run doctests anymore due to this
bug, unless I install old ipython again...

Ondrej


More information about the IPython-dev mailing list