[IPython-dev] IPython.ipapi stopped working

Ondrej Certik ondrej at certik.cz
Wed Oct 14 14:27:42 EDT 2009


On Wed, Oct 14, 2009 at 11:26 AM, Ondrej Certik <ondrej at certik.cz> wrote:
> 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...

And I also can't run isympy:

$ bin/isympy
Traceback (most recent call last):
  File "bin/isympy", line 153, in <module>
    main()
  File "bin/isympy", line 147, in main
    init_session('ipython', **args)
  File "sympy/interactive/__init__.py", line 98, in init_session
    ip = IPython.ipapi.get()
AttributeError: 'module' object has no attribute 'ipapi'


so this is *extremely* annoying. We might have used the IPython api's
improperly though.

Ondrej



More information about the IPython-dev mailing list