ipython icon indicating copy to clipboard operation
ipython copied to clipboard

IronPython - AttributeError: 'module' object has no attribute 'core'

Open kerray opened this issue 13 years ago • 7 comments

I'm trying to run IPython under IronPython following https://github.com/ipython/ipython/wiki/Frequently-asked-questions#wiki-q-can-ipython-run-under-ironpython and I'm getting this traceback on line 764 of init_hooks: hooks = IPython.core.hooks

c:\IronPython 2.7>ipy -X:Frames "c:/ironpython 2.7/scripts/ipython"
Traceback (most recent call last):
  File "<string>", line 2, in initialize
  File "c:\IronPython 2.7\lib\site-packages\IPython\terminal\ipapp.py", line 335, in init_shell
  File "c:\IronPython 2.7\lib\site-packages\IPython\config\configurable.py", line 349, in instance
  File "c:\IronPython 2.7\lib\site-packages\IPython\terminal\interactiveshell.py", line 310, in __init__
  File "c:\IronPython 2.7\lib\site-packages\IPython\core\interactiveshell.py", line 460, in __init__
  File "c:/ironpython 2.7/scripts/ipython", line 6, in <module>
  File "c:\IronPython 2.7\lib\site-packages\IPython\__init__.py", line 118, in start_ipython
  File "c:\IronPython 2.7\lib\site-packages\IPython\config\application.py", line 537, in launch_instance
  File "c:\IronPython 2.7\lib\site-packages\IPython\config\application.py", line 89, in catch_config_error
  File "c:\IronPython 2.7\lib\site-packages\IPython\terminal\ipapp.py", line 321, in initialize
  File "c:\IronPython 2.7\lib\site-packages\IPython\core\interactiveshell.py", line 764, in init_hooks
AttributeError: 'module' object has no attribute 'core'    

I'll gladly investigate further, but at the moment I'd be glad for any ideas. Thanks.

kerray avatar Aug 19 '13 10:08 kerray

Can you do

import IPython.core.hooks

from a regular Python terminal?

minrk avatar Aug 19 '13 14:08 minrk

OK, I installed a clean Python 2.7.5 and using setup.py installed the same version of IPython. The line with import works, IPython in general also works, of course.

However, I tried the import by itself in IronPython terminal and it also imported all right.

kerray avatar Aug 20 '13 09:08 kerray

I put a pdb breakpoint before the error, and I learned that

(Pdb) pp IPython
<module 'IPython' from 'c:\IronPython 2.7\lib\site-packages\IPython\__init__.py'>

(Pdb) p dir(IPython)
['Application', 'Config', 'InteractiveShell', 'TryNext', '__author__', '__builtins__', '__doc__', '__file__', '__license__', '__name__', '__package__', '__path__', '__version__', 'absolute_import', 'config.loader', 'core.getipython', 'embed', 'embed_kernel', 'external', 'extract_module_locals', 'get_ipython', 'lib', 'os', 'release', 'start_ipython', 'start_kernel', 'sys', 'sys_info', 'terminal.embed', 'test', 'testing', 'utils', 'version_info']

kerray avatar Aug 20 '13 11:08 kerray

ok, I worked around these problems, it's ugly but it worked - seems it has something to do with the way IronPython imports modules

so I did

import IPython.core.hooks as HOOKS

and then I replaced IPython.core.hooks references by HOOKS in the entire interactiveshell.py

after this it still failed with

  File "c:\IronPython 2.7\lib\site-packages\IPython\core\interactiveshell.py", line 1783, in init_readline
    import IPython.utils.rlineimpl as readline
AttributeError: 'module' object has no attribute 'utils'

so I just added an

import IPython

directive on top of the file and voila - I was successfully able to

from IPython import start_ipython
start_ipython()

kerray avatar Aug 20 '13 11:08 kerray

That seems like a bug in IronPython - you might want to ask the IronPython team about it.

takluyver avatar Aug 20 '13 16:08 takluyver

Looks like this has been fixed in IronPython and can be closed?

varzan avatar Jan 31 '14 18:01 varzan

I don't think it was ever a bug for us to fix anyway. Closing.

takluyver avatar Jan 31 '14 18:01 takluyver