6

I previously thought that was the issue with IPython, but today I tested again, here is what I did:

  1. Run emacs -Q in cmd window
  2. Open a .py file
  3. M-x, then run python-shell-switch-to-shell, RET, and RET. Then I have the Python shell ready
  4. I in put the following code then:
Python 2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib.pyplot as plt
>>> plt.ion()
>>> plt.plot([1,2,3])
[<matplotlib.lines.Line2D object at 0x03068610>]
>>>

Actually after this, no figure shows up, and the shell is frozen, e.g., when I input:

>>> print("hello")

nothing happened...I haven't tested other plotting tools but matplotlib. I don't know if it is a bug. I've searched for a while, here and though Google, but no luck. My system is: Emacs 24.3 32 bit for Windows, under Windows 7. If others can duplicate same issue as here, I will report this as a bug.

I used IPython as the Python shell by:

C:/Python27/python.exe -i C:/Python27/Scripts/ipython-script.py --pylab

Then, I input figure(); plot([1,2,3]), as expected, the figure popup and freezes. Then I did: C-c C-d which runs comint-send-eof, and the figure actually get updated! But my IPython shell session is also terminated with the following message:

In [6]:
Do you really want to exit ([y]/n)?
Traceback (most recent call last):
File "C:/Python27/Scripts/ipython-script.py", line 9, in <module>
load_entry_point('ipython==0.13.1', 'console_scripts', 'ipython')()
SystemExit

If you suspect this is an IPython bug, please report it at:
https://github.com/ipython/ipython/issues
or send an email to the mailing list at ipython-dev@scipy.org

You can print a more detailed traceback right now with "%tb", or use "%debug"
to interactively debug it.

Extra-detailed tracebacks for bug-reporting purposes can be enabled via:
%config Application.verbose_crash=True

Any helpful clue here?!

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
shelper
  • 10,053
  • 8
  • 41
  • 67
  • I tried it on GNU Emacs 24.2.1 on Fedora 18 and it works fine, sorry. But the hook on my system is ``python-switch-to-python``. – Velimir Mlaker Jun 14 '13 at 22:29
  • you are having issues with the gui main loop. What backend are you using? Try configuring it to use `ipython --pylab` instead of `python` – tacaswell Jun 15 '13 at 03:50
  • @tcaswell i actually tried different backends using matplotlib.use(), does not work. But in cmd window, it works. i also tried ipython, there is a figure window shows up, but it freezes without plot.I believe this post describes the same issue [here on Stackoverflow](http://stackoverflow.com/questions/9101800/emacs-python-inferior-shell-not-showing-prompt-after-matplotlib-show-command), almost 1 year past, still no true answer to the question... I believe it is duplicable if you dont mind to try it with same configuration – shelper Jun 15 '13 at 15:52
  • I don't have a windows box set up to do any real work. Are you passing python the proper threading arguments when you start the interpreter? `matploblib.use()` needs to be run before you import `plt`. I suspect your system is not configured quite right. – tacaswell Jun 15 '13 at 17:13
  • here is my command for Run Python shell in emacs: `C:/Python27/python.exe -i C:/Python27/Scripts/ipython-script.py --pylab` , my ipython is 0.13.2, my python is 2.7.5, the default backend is : TkAgg, As i said, it works under cmd window, so i believe it is not the backend cause the problem. I also tried QT. – shelper Jun 15 '13 at 17:24
  • Today i tested one more time and find something that maybe helpful to solve the problem, i 've added it to the question. however, i am a newbie of emacs and elisp, i wish sb. else who is familiar with python.el and emacs can help to solve the problem with the added info above – shelper Jun 21 '13 at 19:27

2 Answers2

4

one solution is:

(setq python-shell-interpreter "C:\\YourPython3Dist\\python.exe"
      python-shell-interpreter-args "-i C:\\YourPython3Dist\\Scripts\\ipython3-script.py console --pylab=qt")

The Argument console in the call of ipython-script.py is the important one!

In Python 3 with qt backend it works for me. I don't know how it works with py 2.7. (should be no problem if these arguments are supported for ipytho-script.py)

Siegfried
  • 56
  • 4
  • you are the man made my life easier! it works for python 2.7 as well! – shelper Oct 04 '13 at 14:42
  • Yea when they introduced the console argument it started working. I had this problem prior to version 1.0 of Ipython – octi Feb 21 '14 at 15:51
  • @siegfried I am using the WinPython distribution and `ipython3-script.py` is not in the distribution. Any idea what this like should look like in this setup? I am experiencing the same hanging behavior. – Neoasimov Jun 29 '16 at 18:09
1

I think it would take sometime until the problem is fixed. Until some Windows user actually debugs python.el.

Until then, why not try Emacs IPython Notebook? It is a better IPython binding for Emacs. You don't need to use the notebook part. You can think it as a replacement for python shell in python.el. (disclaimer: I am the author)

tkf
  • 2,990
  • 18
  • 32
  • My experience is that ipython is not so great for windows, the notebook often has kernel crash for me, i tried on different machine but same thing happens. I believe that is because the ipython notebook itself requires to set up an http server whose compatibility is not perfect under Windows. Anyway, thanks for making EIN, its a great package for Emacs, and i am actually using it. – shelper Jun 16 '13 at 00:32
  • If it is kernel, the problem is probably zmq, not http (tornado). Did you send a bug report? I think IPython dev is quicker to fix the problem when it comes to Windows. And glad you like EIN :) – tkf Jun 16 '13 at 01:00
  • if you have time ,could you please help to take a look at the question updates? i wonder if that can help to solve the problem, thanks! – shelper Jun 21 '13 at 19:42
  • I don't know much about python.el internal, so I don't know how to fix. I think you can just send a bug report to emacs devel. – tkf Jun 21 '13 at 21:33