Windows: py-shell-complete or ipython-complete doesn't work with emacs 24.1

Bug #1102226 reported by deuscovrigus@gmail.com
14
This bug affects 3 people
Affects Status Importance Assigned to Milestone
python-mode.el
Fix Released
Medium
Andreas Roehler

Bug Description

So I have been trying to get ipython completion for a while now and I can't seem to get it working on windows .

I installed python-mode 6.1.0 , ipython-2927 , on Emacs 24.1. My current ipython version is 0.10.2.

The reason I didn't switch to 0.13 is that matplotlib figures will hang my shell if in interactive mode in emacs. (they work normally if I invoke ipython from a cmd shell) (issue is described and solved here for python 0.10 http://stackoverflow.com/questions/4701607/running-matplotlib-or-enthought-mayavi-mlab-from-a-py-shell-inside-emacs-on-wind)

This is another bug which I only mention here but don't know to whom to address ( the maintainers of python-mode, matplolib or the emacs eshell for windows , ipython ). If you think it is relevant I can open a bug here.

Now back to the completion bug:

I use a bat file as the py-shell-name variable containing

[ipython.bat] @python.exe -i C:\devel\Python\2.7-bin\Scripts\ipython.py --pylab %*
Completion works perfectly when I run ipython from a windows cmd shell.

so for example when I invoke ipython complete on

import cv2.cv as cv
np.<TAB>

Debugger entered--Lisp error: (wrong-type-argument stringp nil)
  format(nil "cv.")
  ipython-complete()
  call-interactively(ipython-complete nil nil)

Then if I do
np. <M-x py-shell-complete>

I get this ugly back-trace:

[ugly-return sep py-which-bufname python-process beg end nil ";" get-buffer-process get-process ...] 7 "Try to complete the python symbol before point. Only knows about the stuff
in the current *Python* session." nil], 8

Repeatedly invoking ipython-complete or py-shell-complete yields

ipython-complete: Wrong type argument: stringp, nil

Is this an active bug? Would I need to mention anything to reproduce it?

Changed in python-mode:
assignee: nobody → Andreas Roehler (a-roehler)
milestone: none → 6.1.1
importance: Undecided → Medium
Revision history for this message
Andreas Roehler (a-roehler) wrote :

Checked in a fix which might not help yet, as it's against a very recent completion bug.
You could try the current trunk nonetheless.

Revision history for this message
deuscovrigus@gmail.com (deuscovrigus) wrote :

I branced rev 1193 but still no dice. As an update, I installed iPython 0.13, ipython.el 2927 and python-mode 6.1.0 on emacs 24.1 on a separate windows machine and py-shell-complete works by invoking py-complete. The only problem is that after a string has been completed the completion window doesn't automatically close.

So I'm guessing this bug is only relevant to iPython 0.10. But like I said, I can't switch to 0.13 yet since matplotlib figures freeze in emacs/ipython. I will open a bug concerning this issue.

Revision history for this message
Andreas Roehler (a-roehler) wrote : Re: [Bug 1102226] Re: py-shell-complete or ipython-complete doesn't work with emacs 24.1 and Windows

Am 23.01.2013 18:53, schrieb <email address hidden>:
> I branced rev 1193 but still no dice. As an update, I installed iPython
> 0.13, ipython.el 2927 and python-mode 6.1.0 on emacs 24.1 on a separate
> windows machine and py-shell-complete works by invoking py-complete. The
> only problem is that after a string has been completed the completion
> window doesn't automatically close.
>

might be the same as lp:1065468

> So I'm guessing this bug is only relevant to iPython 0.10. But like I
> said, I can't switch to 0.13 yet since matplotlib figures freeze in
> emacs/ipython. I will open a bug concerning this issue.
>

okay, thanks

Changed in python-mode:
milestone: 6.1.1 → 6.2
Revision history for this message
Bruce Tulloch (debian-k) wrote : Re: py-shell-complete or ipython-complete doesn't work with emacs 24.1 and Windows

I can confirm this bug (or one very similar) exists on Emacs 24.2.1 on Debian Wheezy with ipython 0.13.1. It looks like it's probably related to bug 1027265 (Filename completion fails in ipython buffer) for which I see a fix is reported committed. Any chance of this one being fixed and released sooner than 6.2?

Revision history for this message
Bruce Tulloch (debian-k) wrote :

I forgot to mention, tested with the head as of today: r1199.

Revision history for this message
Andreas Roehler (a-roehler) wrote : Re: [Bug 1102226] Re: py-shell-complete or ipython-complete doesn't work with emacs 24.1 and Windows

Am 08.02.2013 05:27, schrieb Bruce Tulloch:
> I can confirm this bug (or one very similar) exists on Emacs 24.2.1 on
> Debian Wheezy with ipython 0.13.1. It looks like it's probably related
> to bug 1027265 (Filename completion fails in ipython buffer) for which I
> see a fix is reported committed. Any chance of this one being fixed and
> released sooner than 6.2?
>

IMO it displays the limitations of the way Emacs stuff is developed, i.e. by exchanging code people
use itself basically.

Being well aware of that limitation, looking for people who are interested to change that.
Maybe you are?

Revision history for this message
Bruce Tulloch (debian-k) wrote : Re: py-shell-complete or ipython-complete doesn't work with emacs 24.1 and Windows

I agree. I'd like to solve this myself, but I don't know where to start. I use emacs but I'm not an elisp coder and I'm relatively new to python but have a lot experience with other languages. I can test stuff and report what I find if it helps you and others more familiar with how it's all put together.

Revision history for this message
Andreas Roehler (a-roehler) wrote : Re: [Bug 1102226] Re: py-shell-complete or ipython-complete doesn't work with emacs 24.1 and Windows

Am 08.02.2013 10:21, schrieb Bruce Tulloch:
> I agree. I'd like to solve this myself, but I don't know where to start.
> I use emacs but I'm not an elisp coder and I'm relatively new to python
> but have a lot experience with other languages. I can test stuff and
> report what I find if it helps you and others more familiar with how
> it's all put together.
>

If you want to have a closer look into python-mode.el, start with py-beginning-of-statement.

Revision history for this message
Jerome BESNARD (jerome-besnard) wrote : Re: py-shell-complete or ipython-complete doesn't work with emacs 24.1 and Windows

Hitting my head on the same (I think) issue, it seems to come from ipython.el and python-mode.el using the same variable name ipython-completion-command-string. Since python-mode made this parameter buffer-local, it will be nil in the format command around line 365 in ipython. Hence the error there (since the TAB is for me bound to ipython-complete).

So using ipython and python-mode is not a good idea... Since ipython requires python-mode, you are left with using only python-mode.

In this particular case, using the Anaconda distribution under MSWindows, and python3.3 / ipython0.13.2 does not yield reasonnable results for me. Completion works in a non reasonnable way, i.e. only completing to filenames. This, when my TAB key is bound to py-shell-complete. If I manually call ipython-complete (coming from python-mode), it works better (with ^M, but I should be able to make this work).

Not sure if I was any helpful. It really seems to me (and I will try to dig further) that everything is there to make it work even under windows systems, but that the current python-mode confiiguration is not easy, especially if you keep using ipython.el (which you should not).

Revision history for this message
Andreas Roehler (a-roehler) wrote : Re: [Bug 1102226] Re: py-shell-complete or ipython-complete doesn't work with emacs 24.1 and Windows

Am 06.06.2013 11:44, schrieb Jerome BESNARD:
> Hitting my head on the same (I think) issue, it seems to come from
> ipython.el and python-mode.el using the same variable name ipython-
> completion-command-string. Since python-mode made this parameter buffer-
> local, it will be nil in the format command around line 365 in ipython.
> Hence the error there (since the TAB is for me bound to ipython-
> complete).
>
> So using ipython and python-mode is not a good idea... Since ipython
> requires python-mode, you are left with using only python-mode.
>

Please try to not load ipython.el. If this is not possible, try
(unload-feature 'ipython)

> In this particular case, using the Anaconda distribution under
> MSWindows, and python3.3 / ipython0.13.2 does not yield reasonnable
> results for me. Completion works in a non reasonnable way, i.e. only
> completing to filenames.

Let's say completion is a complex matter, a lot of bugs like this are still around.
Finally dabbrev-expand does often the best for me - while all kind of auto-completes
feel rather distractive soon. But that's a matter of taste too.
In any case (auto)-completion should work.

  This, when my TAB key is bound to py-shell-
> complete. If I manually call ipython-complete (coming from python-mode),
> it works better (with ^M, but I should be able to make this work).
>
> Not sure if I was any helpful. It really seems to me (and I will try to
> dig further) that everything is there to make it work even under windows
> systems, but that the current python-mode confiiguration is not easy,
> especially if you keep using ipython.el (which you should not).
>

Thanks reporting,

Andreas

Revision history for this message
Andreas Roehler (a-roehler) wrote : Re: py-shell-complete or ipython-complete doesn't work with emacs 24.1 and Windows

No idea why the Python completion code working at GNU/Linux fails at windows. Let's see if someone sends a patch. Re-sign for the moment :)

Andreas

Changed in python-mode:
assignee: Andreas Roehler (a-roehler) → nobody
status: New → Confirmed
summary: - py-shell-complete or ipython-complete doesn't work with emacs 24.1 and
- Windows
+ Windows: py-shell-complete or ipython-complete doesn't work with emacs
+ 24.1
Changed in python-mode:
status: Confirmed → In Progress
assignee: nobody → Andreas Roehler (a-roehler)
Revision history for this message
Andreas Roehler (a-roehler) wrote :

With commit r1606 following this post

completion in IPython at Windows here works the following way:

M-x python RET

which opened a python2.7 shell

import IPython
IPython.embed()

after

import sys

sys. TAB displays the completions as attached

Changed in python-mode:
status: In Progress → Fix Committed
Changed in python-mode:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.