[IronPython] Embedding IPython Shell into IronPython

vaggi vaggi at cosbi.eu
Sun Feb 6 12:55:59 CET 2011


Hi,

I was trying to embed IPython into an IronPython application, or even to
call it from the shell, but ran into a few issues.  Google is not very
helpful:

The IPython FAQ gives this, updated in 2009:
http://ipython.scipy.org/moin/FAQ#head-5c9e93fe368aa40bdbb72214bfe164b617bbb21a

but:
http://ipython.scipy.org/moin/Developer_Zone

Here it says that iPython needs to run on IronPython.

A little snippet trying to summon an embedded shell from the IronPython
shell:

IronPython 2.7 Beta 1 (2.7.0.10) on .NET 4.0.30319.1
Type "help", "copyright", "credits" or "license" for more information.
>>> ^V
  File "<stdin>", line 1
    ▬

    ^
SyntaxError: unexpected token '▬'

>>> import IPython
>>> embedshell = IPython.Shell.IPShellEmbed(argv=["-colors", "NoColor"])
<string>:1: DeprecationWarning: object.__new__() takes no parameters
WARNING: Could not import 'ipy_system_conf'
WARNING: Readline services not available on this platform.
>>> embedshell()
ERROR: Internal Python error in the inspect module.
Below is the traceback from this internal error.

Traceback (most recent call last):
  File "C:\Python27\Lib\site-packages\IPython\ultraTB.py", line 665, in
text
    call = tpl_call % (func,inspect.formatargvalues(args,
  File "C:\Program Files (x86)\IronPython 2.7\Lib\inspect.py", line 885, in
form
atargvalues
    specs.append(strseq(args[i], convert, join))
  File "C:\Program Files (x86)\IronPython 2.7\Lib\inspect.py", line 840, in
strs
eq
    return convert(object)
  File "C:\Program Files (x86)\IronPython 2.7\Lib\inspect.py", line 882, in
conv
ert
    return formatarg(name) + formatvalue(locals[name])
KeyError: self

IPython's exception reporting continues...

ERROR: Internal Python error in the inspect module.
Below is the traceback from this internal error.

Traceback (most recent call last):
  File "C:\Python27\Lib\site-packages\IPython\ultraTB.py", line 665, in
text
    call = tpl_call % (func,inspect.formatargvalues(args,
  File "C:\Program Files (x86)\IronPython 2.7\Lib\inspect.py", line 885, in
form
atargvalues
    specs.append(strseq(args[i], convert, join))
  File "C:\Program Files (x86)\IronPython 2.7\Lib\inspect.py", line 840, in
strs
eq
    return convert(object)
  File "C:\Program Files (x86)\IronPython 2.7\Lib\inspect.py", line 882, in
conv
ert
    return formatarg(name) + formatvalue(locals[name])
KeyError: self

IPython's exception reporting continues...

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)

C:\Windows\system32\<stdin> in <module>()
----> 1
      2
      3
      4
      5

C:\Python27\Lib\site-packages\IPython\Shell.py in __call__(***failed
resolving a
rguments***)
    240         # Call the embedding code with a stack depth of 1 so it can
skip
 over
    241         # our call and get the original caller's namespaces.
--> 242        
self.IP.embed_mainloop(banner,local_ns,global_ns,stack_depth=1)
    243
    244         if self.exit_msg:

C:\Python27\Lib\site-packages\IPython\iplib.py in embed_mainloop(***failed
resol
ving arguments***)
   1806
   1807         # Get locals and globals from caller
-> 1808         if local_ns is None or global_ns is None:
   1809             call_frame = sys._getframe(stack_depth).f_back
   1810

AttributeError: 'module' object has no attribute '_getframe'
>>>

Furthermore, there were some posts found by google in 2009 suggesting that
some progress had been made, but I couldn't find the follow up.

Anyone gotten further?  I am still a bit stumped about exactly what is
involved in making it work.  Alternatively, are there any easier ways of
embedding a python-like shell in an IronPython application?

Federico




More information about the Ironpython-users mailing list