Issue with IPython

Apr 17, 2011 at 8:21 AM

I tried setting the interactive mode to IPython, but I get the following error when running a program via Execute in PI:

Error using selected REPL back-end:
IPython mode requires IPython 0.11 or later.
Using standard backend instead

AFAIK the latest stable version of IPython is 0.10.2. What am I missing? Do we have to use dev branch?

Thanks!

Editor
Apr 17, 2011 at 1:40 PM

Yes, you have to use the dev branch.

Apr 18, 2011 at 2:47 AM
Edited Apr 18, 2011 at 2:48 AM

Ah, thats unfortunate as .11 breaks PythonXY's shell extension.

I configured a separate CPython 2.6 installation (using virtualenv) and installed the latest version of IPython, but I am still having issues getting PTVS to work with it. After configuring a new python interpreter in VS and copying the settings from the default (except the location of course), I tried running this script:

 

import IPython
print "IPython version is " + IPython.__version__

 

The result in interactive is:

Running C:\Users\kyon\documents\visual studio 2010\Projects\IPythonEmbedTest\IPythonEmbedTest\Program.py
Error using selected REPL back-end:
IPython mode requires IPython 0.11 or later.
Using standard backend instead
IPython version is 0.11.dev

It seems the python interpreter being invoked is using IPython 0.11.dev but PTVS is still not accepting it. Any ideas?

As an aside, I was able to generate exceptions and even crash VS by adding/removing interpreters in  Tools->Options->Python Tools-> Interactive <...>. In particular:

- If I add and then delete an interpreter in interpreter options, it will still shows up in interactive windows until VS is restarted. Selecting it gives a KeyNotFoundException, full stack trace below.

- If i type "2.6" (no quotes) into the language version box I get a warning box saying "version is not in invalid format and will not be updated",  but 2.6 is what is entered in for the default interpreter.

- If I add a new interpreter in options, cannot set its interactive mode unless Options window is reopened. Doing so still causes the exception shown below, until VS is restarted.

- Adding and deleting interpreters caused VS to crash at one point, wasn't able to reproduce it.

System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
   at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
   at Microsoft.PythonTools.Options.PythonInteractiveOptionsControl.get_CurrentOptions()
   at Microsoft.PythonTools.Options.PythonInteractiveOptionsControl.RefreshOptions()
   at Microsoft.PythonTools.Options.PythonInteractiveOptionsControl._showSettingsFor_SelectedIndexChanged(Object sender, EventArgs e)
   at System.Windows.Forms.ComboBox.OnSelectedIndexChanged(EventArgs e)
   at System.Windows.Forms.ComboBox.WmReflectCommand(Message& m)
   at System.Windows.Forms.ComboBox.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
   at System.Windows.Forms.UnsafeNativeMethods.SendMessage(HandleRef hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
   at System.Windows.Forms.Control.SendMessage(Int32 msg, IntPtr wparam, IntPtr lparam)
   at System.Windows.Forms.Control.ReflectMessageInternal(IntPtr hWnd, Message& m)
   at System.Windows.Forms.Control.WmCommand(Message& m)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
   at System.Windows.Forms.UserControl.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

Sep 13, 2011 at 11:16 AM

I have installed the IPython 0.11 release version and configured interactive mode to "IPython" and am getting the same error as kyon:

Error using selected REPL back-end:
IPython mode requires IPython 0.11 or later.
Using standard backend instead

Am I doing something wrong? I can import IPython and assert its version from that very same interactive window:

>>> import IPython
>>> IPython.__version__
'0.11'

Coordinator
Sep 13, 2011 at 5:32 PM

This is usually caused by not having ZeroMQ installed (IPython uses zmq for it's communication, but it's not required for just the basic IPython experience - only if someone is hosting IPython).  If you have easy_install you can just do an easy_install.exe pyzmq and it should work.

If that's not the issue I can tell you how to make it print the exception which is preventing IPython from loading - we should probably do that by default instead of hiding it.

Sep 14, 2011 at 11:29 AM

I'm trying to install pyzmq but it complains that it cannot find the ZMQ directory. Do I need to first build and install ZMQ before I easy_install pyzmq?

Here is the output I get:-

 >easy_install pyzmq
Searching for pyzmq
Reading http://pypi.python.org/simple/pyzmq/
Reading http://github.com/zeromq/pyzmq
Reading http://github.com/zeromq/pyzmq/downloads
Best match: pyzmq 2.1.9
Downloading https://github.com/downloads/zeromq/pyzmq/pyzmq-2.1.9.zip
Processing pyzmq-2.1.9.zip
Running pyzmq-2.1.9\setup.py -q bdist_egg --dist-dir c:\users\dfortu~1\appdata\local\temp\easy_install-x0rm3f\pyzmq-2.1.9\egg-dist-tmp-9i91gp
Fatal: ZMQ directory must be specified on Windows via setup.cfg or 'python setup.py configure --zmq=/path/to/zeromq2'
error: Setup script exited with 1
Coordinator
Sep 14, 2011 at 6:24 PM

I'm not sure why that wouldn't work (maybe a bug in the setup script for zeromq?) I'd suggest trying the binary installers instead: https://github.com/zeromq/pyzmq/downloads

Sep 15, 2011 at 9:45 AM

Yeah, I held off on that because the latest version didn't have a binary distribution for python 2.6 but I've now installed a slightly older 'pyzmq-2.1.4.win32-py2.6.msi' and it all works fine. Thanks!

Oct 23, 2011 at 2:06 AM

Hi,

I've just started using PTVS with IPython 0.11 and I'm getting the same error:

Error using selected REPL back-end:
IPython mode requires IPython 0.11 or later.
Using standard backend instead

I've installed pyzmq but that hasn't sorted it. Any other suggestions?

Thanks.

Coordinator
Oct 24, 2011 at 11:46 PM

darwinian, Can you open a Python REPL and run:

 

 

from IPython.zmq import kernelmanager

 from IPython.zmq.kernelmanager import ShellSocketChannel, KernelManager, SubSocketChannel, StdInSocketChannel, HBSocketChannel

 

from IPython.utils.traitlets import Type

 

And see what exceptions you get? 

Oct 30, 2011 at 10:30 AM

Hi dinov, thanks for the reply.

I ran the imports and... no errors at all.

Coordinator
Oct 31, 2011 at 11:13 PM

Could it have accidently been in different REPLs - in other words did you try it from the VS repl or a normal CMD repl?  It might be best to try it from the VS repl after you get the error just to make sure everything else is the same.

Oct 31, 2011 at 11:49 PM

Apologies, I hadn't realised you meant from the VS IPython REPL. Unfortunately I now have a different issue preventing me from trying: VS no longer detects IPython as an available REPL. I've tried reinstalling PTVS and still nothing, despite IPython being installed and working. Is there a way to force PTVS to detect it?

Thanks.

Coordinator
Nov 1, 2011 at 6:08 PM

What do you mean "as an available REPL"?  Do you mean you no longer have "View->Other Windows->Python ..." or that Tools->Options->Interactive Windows->Interactive Mode no longer lists IPython as an available mode?

If it's the former what versions of Python do you have installed and where did the distro come from (e.g. python.org, Enthought, ActiveState, etc...)?

Nov 1, 2011 at 10:16 PM

I mean IPython no longer appears under Tools->Options->Interactive Windows->Interactive Mode. The only option available is the standard Python 2.7 interactive window. I have the Enthought 7.1 free distribution installed.

Coordinator
Nov 1, 2011 at 11:11 PM

One possible solution is to paste visualstudio_ipython_repl.IPythonBackend into the text box (which is what IPython magically turns into).

I'm not really sure what would cause this to go away, this should be registered in our .pkgdef file (in %LOCALAPPDATA%\Microsoft\VisualStudio\10.0\Extensions\Microsoft\Python Tools for Visual Studio\1.0\Microsoft.PythonTools.pkgdef if you did a per-user install, or in VsInstallDir\Common7\IDE\Extensions\Microsoft\Python Tools for Visual Studio\1.0\Microsoft.PythonTools.pkgdef for the default all users install).  This actually should always be there regardless of whether or not IPython is installed.  Does that file still have:

 

[$RootKey$\PythonTools\ReplExecutionModes\{91BB0245-B2A9-47BF-8D76-DD428C6D8974}]
"Type"="visualstudio_ipython_repl.IPythonBackend"
"FriendlyName"="IPython"
"SupportsMultipleScopes"="False"

In it?

Nov 8, 2011 at 9:21 AM

Hi,

I just encountered the same issue, and I found the following was the issue:

in the \<python>\Lib\site-packages\IPython\zmq\__init__.py file

'  minimum_pyzmq_version = "2.1.4"
'
'  try:
'      import zmq
'  except ImportError:
'      raise ImportError("IPython.zmq requires pyzmq >= %s"%minimum_pyzmq_version)

'  pyzmq_version = "2.1.4" #zmq.__version__
'
'  if pyzmq_version < minimum_pyzmq_version:
'    raise ImportError("IPython.zmq requires pyzmq >= %s, but you have %s"%(
'                    minimum_pyzmq_version, pyzmq_version))

 

the issue is that 2.1.10 < 2.1.4, I hardcoded this to pass and now it works.

Ciao

Nov 14, 2011 at 2:39 PM

I had the same issues. I've installed the pyzmq and did the version rename, but after entering an command into the VS REPL the process doesn't return (waitcursor).

Im running Win7 x64, PyTools 1.1 alpha, VS2010 SP1 and a bunch of other extensions. Any hints?

Jun 28, 2012 at 8:02 PM
asqui wrote:

Yeah, I held off on that because the latest version didn't have a binary distribution for python 2.6 but I've now installed a slightly older 'pyzmq-2.1.4.win32-py2.6.msi' and it all works fine. Thanks!


I also had the same problem and getting that same pyzmq binary installer seems to have fixed it.

Jul 1, 2012 at 10:21 AM
Edited Jul 1, 2012 at 4:49 PM

I wasn't sure should I start a new thread or put it here. So I put it here. 

I've installed:

PTVS 1.5 Beta 1.msi
python 2.7.3 win32 
ipython 0.13 py2 win32
pyzmq 2.2.0 win32 (tried 2.1.4 too) 

When I launch test file in python interactive shell I get an error

The Python REPL process has exitedTraceback (most recent call last): 

File "C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\Extensions\Microsoft\Python Tools for Visual Studio\1.5\visualstudio_py_repl.py", line 1092, in <module>   _run_repl() 

File "C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\Extensions\Microsoft\Python Tools for Visual Studio\1.5\visualstudio_py_repl.py", line 1076, in _run_repl    BACKEND = backend_type(launch_file=options.launch_file) 

File "C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\Extensions\Microsoft\Python Tools for Visual Studio\1.5\visualstudio_ipython_repl.py", line 158, in __init__    self.km.start_kernel(**{'ipython': True, 'extra_arguments': self.get_extra_arguments()}) 

File "D:\Tools\Python\Python27_86\lib\site-packages\IPython\zmq\kernelmanager.py", line 806, in start_kernel    self.kernel = launch_kernel(fname=self.connection_file, **kw) 

File "D:\Tools\Python\Python27_86\lib\site-packages\IPython\zmq\ipkernel.py", line 869, in launch_kernel    *args, **kwargs)

TypeError: base_launch_kernel() got an unexpected keyword argument 'ipython'

UPDATE: Have tried PVTS 1.1.1 with no luck too

Coordinator
Jul 24, 2012 at 6:03 PM

Tiphon,

Sorry for the slow response time - This looks like this is a breaking change in IPython .13. To work around this you can remove "'ipython': True," from "C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\Extensions\Microsoft\Python Tools for Visual Studio\1.5\visualstudio_ipython_repl.py" on line 158. I've pinged the IPython team and opened an issue so that we can fix this and support IPython .11 - .13 at same time.

Nov 16, 2013 at 2:22 PM
Hi, I have the same issues. I just solved it by installing "pyzmq" through Anaconda with command: conda install tornado pyzmq