ivanov/vim-ipython

'ZMQSocketChannel' object has no attribute 'execute'

bongbang opened this issue · 9 comments

Windows 7 (64)
Vim 7.4
IPython QtConsole 3.0.0
ZMQ 14.5.0
Python 2.7.9 |Anaconda 2.2.0 (64-bit)|

I was getting exactly the same error described in #95, so I followed the instructions to modify my gvim.exe. Now, I'm getting a different error when calling IPython from vim.

Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\TomV\vimfiles\bundle\vim-ipython\ftplugin\python\vim_ipython.py", line 175, in km_from_string
  send = kc.shell_channel.execute
AttributeError: 'ZMQSocketChannel' object has no attribute 'execute'  

I have experimented with different versions of DLLs installed on my computer, with the same result.

Same mistake here, on a different platform though:

  • Archlinux x64
  • gvim 7.4.663-2
  • ipython2 3.1.0-1
  • python2-pyzmq 14.5.0-2
  • zeromq 4.0.5-1

I don't think master is compatible with IPython3, but there are PRs #114 and #119

Same here:
OS X
vim 7.4.488
python 2.7.9
ipython 3.1.0
pymzq 14.6.0
zeromq 4.0.5

Also, related to @bfredl comment, i just downgraded my ipython to version 2.1.0 and i got a different error:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Users/josefson/dotfiles/vim/ftplugin/python/vim_ipython.py", line 151, in km_from_string
    km.load_connection_file()
  File "/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/IPython/kernel/connect.py", line 498, in load_connection_file
    self.ip = cfg['ip']
KeyError: 'ip'

Also, tried the #119 with ipython3, but no luck!
I really hope i could use this software.

I use it with ipython 2.0 in a virtual environment and it works! I got the same error with ipython 3

I still get this message with master and the newly merged #119 and ipython3

Same here. I have seen multiple error reports with this plug-in which is a pity because if it worked it would be great and one of its kind! I have spent a number of hours already trying to make it work in my ubuntu box and still it won't work with every new thing I attempt. This is what I get

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/carlos/.vim/bundle/vim-ipython/ftplugin/python/vim_ipython.py", line 175, in km_from_string
    send = kc.shell_channel.execute
AttributeError: 'ZMQSocketChannel' object has no attribute 'execute'

I am under Python 2.7.10 |Anaconda 2.1.0 (64-bit)| IPython 3.1.0

A little more information from my side. I've got the exact same error on my CentOS box, but not my Ubuntu box.
I have vim-ipython working on my Ubuntu 14.04 laptop, with Python 2.7.6 and IPython 1.2.1. I fired up an IPython session and ran the following code snippet from vim_ipython.py . I had an error on line 175 as well, so I decided to check out the members of kc.shell_channel

In [2]: from IPython.kernel import KernelManager

In [3]: km = KernelManager()

In [4]: kc = km.client()

In [6]: dir(kc.shell_channel)
Out[6]: 
['_Thread__args',  '_Thread__block',  '_Thread__bootstrap',  '_Thread__bootstrap_inner',
 '_Thread__daemonic',  '_Thread__delete',  '_Thread__exc_clear',  '_Thread__exc_info',
 '_Thread__ident',  '_Thread__initialized',  '_Thread__kwargs',  '_Thread__name',
 '_Thread__started',  '_Thread__stderr',   '_Thread__stop',  '_Thread__stopped',  '_Thread__target',
 '_Verbose__verbose',  '__class__',   '__delattr__',  '__dict__',   '__doc__', '__format__',
 '__getattribute__',  '__hash__',  '__init__',  '__module__',   '__new__', '__reduce__',
 '__reduce_ex__',  '__repr__',   '__setattr__',  '__sizeof__',  '__str__', '__subclasshook__',
 '__weakref__',  '_address',  '_block',  '_exiting', '_handle_recv', '_in_queue', '_note', '_notice_exit',
 '_queue_send', '_reset_internal_locks', '_run_loop', '_set_daemon', '_set_ident', 'address',
 'allow_stdin', 'call_handlers', 'command_queue', 'complete', 'context', 'daemon',*** 'execute'***,
 'getName', 'get_msg', 'get_msgs', 'history', 'ident', 'ioloop', 'isAlive', 'isDaemon', 'is_alive', 'join',
 'kernel_info', 'msg_ready', 'name', **'object_info'**, 'proxy_methods', 'run', 'session', 'setDaemon', 'setName', 'shutdown', 'socket', 'start', 'stop', 'stream']

As you can see, execute, and object_info which appears on line 179 in vim_ipython.py, is present in the kc.shell_channel class on IPython 1.2.1. All works well here.

But the output of dir(kc.shell_channel) on my CentOS box, with Python 2.7.9 and IPython 3.1.0 gives me this -

In [1]: from IPython.kernel import KernelManager

In [2]: km = KernelManager()

In [3]: kc = km.client()

In [4]: dir(kc.shell_channel)
Out[4]: 
['__class__', '__delattr__', '__dict__', '__doc__', '__format__', '__getattribute__', '__hash__',
 '__init__', '__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__',
 '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_exiting', '_recv', 'close', 'get_msg',
 'get_msgs', 'is_alive', 'msg_ready', 'proxy_methods', 'send', 'session', 'socket', 'start', 'stop',
 'stream']

It seems that execute and object_info are no longer part of the kc.shell_channel class on IPython 3.1.0 . I tried changing line 175 of my vim_ipython.py to send = kc.shell_channel.send , but I then got an error on line 179 with num_oinfo_args = len(inspect.getargspec(sc.object_info).args) . This also seems to be because object_info is no longer a member of shell_channel in IPython 3.1.0 .

I really love your plugin, and it works like a charm on my Ubuntu laptop with a dated IPython. I hope this debug info helps you in some way.

Whenever it calls a method on the shell_channel it should call that method on the kernelclient directly, so it should be send = kc.execute (and kc.complete, and kc.inspect instead of sc.object_info)

I've made a PR (#126) that hopefully fixes this issue.