emacs22 and python-mode do not play together

Bug #155681 reported by Michael D. Stemle, Jr.
26
Affects Status Importance Assigned to Milestone
emacs22 (Ubuntu)
Invalid
Undecided
Unassigned
python-mode (Debian)
Fix Released
Unknown
python-mode (Ubuntu)
Fix Released
Undecided
Unassigned

Bug Description

Okay, so if I just load emacs22, and I type `M-x python-mode` I get "Cannot open load file: python-mode".

If I `M-x load-library^Mpython` then I can get a python-mode that seems to be drastically limited when compared to what folks know and love in python-mode under emacs21. All that python-mode seems to include is font-lock-mode (syntax highlighting) functionality... whereas emacs21's python-mode had scope helpers and such built in.

I may be way off base here, but I'd really like to see the python-mode that emacs21 come back for emacs22.

Related branches

Revision history for this message
Paul Sladen (sladen) wrote :

Yes, all you (should) need to do is:

  sudo apt-get install python-mode

This should be compatible with 'emacs22' as that "Provides: emacsen" which is what 'python-mode' depends upon.

Does that solve the problem?

Changed in emacs22:
status: New → Incomplete
Revision history for this message
Michael D. Stemle, Jr. (manchicken) wrote :
Download full text (5.1 KiB)

Nope, this doesn't solve the problem. I do see this in the output of the install:

Wrote /usr/share/emacs22/site-lisp/pymacs/pymacs.elc
emacs22 includes it's own python-mode, skipping installation

Full output of the install is here:
manchicken@thepea:~$ sudo apt-get install python-mode
[sudo] password for manchicken:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
  pymacs
The following NEW packages will be installed:
  pymacs python-mode
0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
Need to get 0B/334kB of archives.
After unpacking 852kB of additional disk space will be used.
Do you want to continue [Y/n]? y
Selecting previously deselected package pymacs.
(Reading database ... 253571 files and directories currently installed.)
Unpacking pymacs (from .../archives/pymacs_0.22-6_all.deb) ...
Selecting previously deselected package python-mode.
Unpacking python-mode (from .../python-mode_1%3a1.0-3.1ubuntu1_all.deb) ...
Setting up pymacs (0.22-6) ...
emacsen-common: Handling install of emacsen flavor emacs
emacsen-common: Handling install of emacsen flavor emacs22
emacsen-common: byte-compiling for emacs22
Loading /etc/emacs22/site-start.d/00debian-vars.el (source)...
Loading /etc/emacs/site-start.d/50autoconf.el (source)...
Loading /etc/emacs/site-start.d/50cmake.el (source)...
Loading /etc/emacs/site-start.d/50dictionaries-common.el (source)...
Loading debian-ispell...
Loading /var/cache/dictionaries-common/emacsen-ispell-default.el (source)...
Loading /var/cache/dictionaries-common/emacsen-ispell-dicts.el (source)...
Loading /etc/emacs/site-start.d/50emacs-goodies-el.el (source)...
Loading /etc/emacs/site-start.d/50festival.el (source)...
Loading /etc/emacs/site-start.d/50php-elisp.el (source)...
Loading /etc/emacs/site-start.d/50psvn.el (source)...
Loading /etc/emacs/site-start.d/50pymacs.el (source)...
Loading /etc/emacs/site-start.d/50python-mode.el (source)...
Loading /etc/emacs/site-start.d/50ruby1.8-elisp.el (source)...
Wrote /etc/emacs22/site-start.d/00debian-vars.elc
Wrote /usr/share/emacs22/site-lisp/debian-startup.elc
install/pymacs: Handling install for emacsen flavor emacs22
Loading 00debian-vars...
Loading /etc/emacs/site-start.d/50autoconf.el (source)...
Loading /etc/emacs/site-start.d/50cmake.el (source)...
Loading /etc/emacs/site-start.d/50dictionaries-common.el (source)...
Loading debian-ispell...
Loading /var/cache/dictionaries-common/emacsen-ispell-default.el (source)...
Loading /var/cache/dictionaries-common/emacsen-ispell-dicts.el (source)...
Loading /etc/emacs/site-start.d/50emacs-goodies-el.el (source)...
Loading /etc/emacs/site-start.d/50festival.el (source)...
Loading /etc/emacs/site-start.d/50php-elisp.el (source)...
Loading /etc/emacs/site-start.d/50psvn.el (source)...
Loading /etc/emacs/site-start.d/50pymacs.el (source)...
Loading /etc/emacs/site-start.d/50python-mode.el (source)...
Loading /etc/emacs/site-start.d/50ruby1.8-elisp.el (source)...
Wrote /usr/share/emacs22/site-lisp/pymacs/pymacs.elc

Setting up python-mode (1:1.0-3.1ubuntu1) ...
emacsen-common: Handling install of emacsen flavor emacs
emacsen-...

Read more...

Revision history for this message
Paul Sladen (sladen) wrote :

<sladen> manchicken: responded, is it still broken?
<manchicken> Nope

Could you please include the output of:

  dpkg -l | awk '/emacs/{print $1,$2}'

and:

  lsb_release -a

Revision history for this message
Michael D. Stemle, Jr. (manchicken) wrote :

manchicken@thepea:~$ dpkg -l | awk '/emacs/{print $1,$2}'
ii emacs
ii emacs-goodies-el
rc emacs21
rc emacs21-bin-common
ii emacs22
ii emacs22-bin-common
ii emacs22-common
ii emacs22-el
ii emacs22-gtk
ii emacs22-nox
ii emacsen-common

manchicken@thepea:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 7.10
Release: 7.10
Codename: gutsy

Revision history for this message
Paul Sladen (sladen) wrote :

and:

  dpkg -l | awk '/pymacs|python-mode/{print $2,$3}'

I made a mistake with the previous dpkg awk command, should be $2 and $3:

  dpkg -l | awk '/emacs/{print $2,$3}'

Revision history for this message
Michael D. Stemle, Jr. (manchicken) wrote :

manchicken@thepea:~$ dpkg -l | awk '/pymacs|python-mode/{print $2,$3}'
pymacs 0.22-6
python-mode 1:1.0-3.1ubuntu1

manchicken@thepea:~$ dpkg -l | awk '/emacs/{print $2,$3}'
emacs 22.1-0ubuntu5
emacs-goodies-el 27.1-1
emacs21 21.4a+1-5ubuntu4
emacs21-bin-common 21.4a+1-5ubuntu4
emacs22 22.1-0ubuntu5
emacs22-bin-common 22.1-0ubuntu5
emacs22-common 22.1-0ubuntu5
emacs22-el 22.1-0ubuntu5
emacs22-gtk 22.1-0ubuntu5
emacs22-nox 22.1-0ubuntu5
emacsen-common 1.4.17

Revision history for this message
Paul Sladen (sladen) wrote :

Confirming, same versions here, and:

  cd ~/tmp
  emacs -nw foo.py

results in:

  File mode specification error: (file-error "Cannot open load file" "python-mode")

Changed in python-mode:
status: New → Incomplete
Changed in python-mode:
status: Unknown → New
Revision history for this message
Douglas Bagnall (douglasbagnall) wrote :

Same versions and problem here.

emacs-snapshot works with python-mode, which may help people who want a 22ish emacs. I have:

emacs-snapshot 1:20070805-1ubuntu1
emacs-snapshot-bin-common 1:20070805-1ubuntu1
emacs-snapshot-common 1:20070805-1ubuntu1
emacs-snapshot-el 1:20070805-1ubuntu1
emacs-snapshot-gtk 1:20070805-1ubuntu1

Revision history for this message
Brad Crittenden (bac) wrote :

This bug is related to bug 134308.

The suggestion there to remove the python-mode package worked for me:

% dpkg --purge python-mode

For python-mode in emacs22 you must have emacs22-el installed and python-mode not installed.

Revision history for this message
Michael D. Stemle, Jr. (manchicken) wrote :

This works for me, too. I think that a fix for this bug would just be to make sure that the emacs22 package conflicts with python-mode.

Revision history for this message
Reinhard Tartler (siretart) wrote :

nope. the correct fix is to make sure that python-mode doesn't install conffiles that break emacs22.

having emacs22 conflicting python-mode would make it impossible to have both emacsen installed and python-mode for emacs21.

Changed in emacs22:
status: Incomplete → Invalid
Revision history for this message
Reinhard Tartler (siretart) wrote :

python-mode (1:1.0-3.1ubuntu2) hardy; urgency=low

  * really don't load for emacs22. LP: #155681

 -- Reinhard Tartler <email address hidden> Wed, 24 Oct 2007 16:43:34 +0200

Changed in python-mode:
status: Incomplete → Fix Released
Revision history for this message
Brad Crittenden (bac) wrote :

Reinhard is correct. I should have labeled my comment as a work-around.

Revision history for this message
Brad Crittenden (bac) wrote :

The problem lies with the file /etc/emacs/site-start.d/50python-mode.el

Python-mode should only be loaded if the version of emacs is not emacs20 or emacs22.

The current test is:

(if (not (or (eq (symbol-name debian-emacs-flavor) "emacs20")
               (eq (symbol-name debian-emacs-flavor) "emacs22")))

It should be:

(if (not (or (string= (symbol-name debian-emacs-flavor) "emacs20")
               (string= (symbol-name debian-emacs-flavor) "emacs22")))

Revision history for this message
Reinhard Tartler (siretart) wrote :

I did exactly this change by uploading python-mode (1:1.0-3.1ubuntu2) to hardy

Revision history for this message
Akkana Peck (akkzilla) wrote :

Can someone clarify the current recommended workaround?

I installed gutsy (as an upgrade to feisty, where I had emacs21 and python-mode installed) on 10/29, after Reinhard Tartler's check-in, but I still hit this problem. So I tried quitting emacs then aptitude remove python-mode (which also took pymacs with it), but after restarting emacs, I still get the same error when I open a python script. Then I tried reinstalling python-mode (which brought pymacs back in) ... same error.

This seems to work:
cp /usr/share/emacs/site-lisp/python-mode/* ~/.emacs-lisp/
Is there a better way?

Revision history for this message
Xavier Martinez-Hidalgo (xavier-martinezhidalgo) wrote :

Removing python-mode is not enough to solve the issue, "purge" must be used to ensure that configuration files are also removed, as suggested by Brad Crittenden.

The following worked for me:

% sudo aptitude purge python-mode

However, this also removes pyrex-mode, as it depends on python-mode, so it seems that pyrex-mode cannot be used with emacs22.

Revision history for this message
piccobello (piccobello) wrote :

Same problem, after installing pyrex-mode, which installed python-mode and pymacs.
Purged the three and now I can use the emacs22 python mode.

 dpkg -l | awk '/emacs/{print $2,$3}'

now gives me

emacs 22.1-0ubuntu5.1
emacs-goodies-el 27.1-1
emacs22-bin-common 22.1-0ubuntu5.1
emacs22-common 22.1-0ubuntu5.1
emacs22-gtk 22.1-0ubuntu5.1
emacsen-common 1.4.17

It's a real pity though, I will have to switch to emacs-snapshot to use pyrex-mode and the original python-mode

Revision history for this message
Nils Fredrik Gjerull (nfg) wrote :

I got this problem on my Gutsy Gibbons installation. The fix provided by Brad Crittenden made emacs22 load it's internal python-mode while python-mode was installed for emacs21 (I need to run both together). However, python-mode did not load in emacs21. The source of this problem was a missing symbolic link to site-lisp in the /usr/share/emacs/21.4 directory. In other words i ran ln -s ../../emacs21/site-lisp in the /usr/share/emacs/21.4 directory. This solved the problem, now I can run python-mode in both emacs22 and emacs21. I am a bit surprised that this is not fixed in the python-mode deb package yet. It is really a simple fix. The symbolic link issue should be solved in the emacs21 package I guess?

Revision history for this message
Erik Forsberg (forsberg) wrote :

Still having this problem on hardy that was updated from repos today. Tried purging python-mode, pyrex and pymacs, doesn't help.

$ dpkg -l | awk '/emacs/{print $2,$3}'
emacs 22.1-0ubuntu10
emacs22-bin-common 22.1-0ubuntu10
emacs22-common 22.1-0ubuntu10
emacs22-el 22.1-0ubuntu10
emacs22-gtk 22.1-0ubuntu10
emacsen-common 1.4.17
lyskom-elisp-client 0.48-10

Can I help someway?

Revision history for this message
sebek (sebeeek) wrote :

I believe the 134308 should be flagged as duplicate of this one

I still can't understand the workaround given by Brad Crittenden on 2007-10-23:
"For python-mode in emacs22 you must have emacs22-el installed and python-mode not installed."

I have removed and purged the python-mode package, and then installed emacs22-el package.
How do I start python-mode then?
M-x python-mode
gives me a
call-interactively: Cannot open load file: python-mode

thanks

Revision history for this message
era (era) wrote :

sebek: works for me on Gutsy (apart from the purging of the python-mode package -- I never installed it). Did you restart Emacs after installing emacs22-el? Can you verify that /usr/share/emacs/22.1/lisp/progmodes/python.el.gz exists on your system and that the path is on your load-path?

Revision history for this message
sebek (sebeeek) wrote :

era : Thank you for your answer.
The python.el.gz was correctly installed.
I found my problem, my .emacs contained :
     (autoload 'python-mode "python-mode" "Python editing mode." t)
It seems that once you tried to activate python mode at startup, it will never starts correctly.
I just commented this line and it is working.

Revision history for this message
Helge Stenström (h-stenstrom) wrote : Re: [Bug 155681] Re: emacs22 and python-mode do not play together

It seems to me that the python modes of emacs22-el
(/usr/share/emacs/22.1/lisp/progmodes/python.el.gz) and of python-mode
(/usr/share/emacs/site-lisp/python-mode/python-mode.el) are totally
different. So, which one is this bug about?

Is there two competing teams of python mode developers? I'm more used
to the mode of the python-mode package, and would prefer that one. In
particular, I like the list of classes and methods, that seems to be
missing from the emacs22-el package.

Revision history for this message
Reinhard Tartler (siretart) wrote :

Helge Stenström <email address hidden> writes:

> It seems to me that the python modes of emacs22-el
> (/usr/share/emacs/22.1/lisp/progmodes/python.el.gz) and of python-mode
> (/usr/share/emacs/site-lisp/python-mode/python-mode.el) are totally
> different. So, which one is this bug about?

This bug is about the interaction of the two packages. Anyway, both
bugtasks have been closed, so AFAIUI, there isn't anything more to do
about this bug.

Regarding using python-mode with emacs22, I'd suggest talking to emacs
upstream and/or the python-mode developers.

--
Gruesse/greetings,
Reinhard Tartler, KeyID 945348A4

Revision history for this message
Erik Forsberg (forsberg) wrote :

sebek: Thankyou! It turns out I also had a '(autoload 'python-mode "python-mode" "Python editing mode." t)' in my ~/.emacs, and removing it removed this mysterious problem.

Revision history for this message
David Kaplan (dmkaplan) wrote :

On hardy, python-mode works automatically for me on loading a .py file without having to install the python-mode packe, but I have found another related problem. I want to use ipython as my defaults emacs python shell. The normal way to do this is to put "(require 'ipython)" in .emacs, but ipython.el has (require 'python-mode) in a number of places which causes the load error.

Therefore, there is still a bug somewhere. Either ipython.el in the ipython package needs to be fixed or python-mode integration with emacs22 needs to be fixed. Please instruct me as to which is the correct "bug" to fix and whether or not to file a separate bug report for this problem or request that this bug be reopened to address this second issue.

Revision history for this message
Emanuele Olivetti (emanuele-relativita) wrote :

Same problem for me on hardy: ipython inside emacs does not work (as default python shell). Even using latest ipython (0.9.1). I had to revert to emacs21 to let it work. Any hint on how to use emacs22 together with ipython in hardy?

Changed in python-mode (Debian):
status: New → 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.