32

I recently upgraded from Emacs 23 to Emacs 24. Since the upgrade, it seems that I've lost the ability to call "M-x python-shell" (!).

What happened? Does the included python mode no longer ship with this functionality?

Using Emacs 23:

○ /usr/local/bin/emacs -Q

Describe function: python-shell
    python-shell is an interactive autoloaded Lisp function in
    `python.el'.

Using Emacs 24:

○ /Applications/Emacs.app/Contents/MacOS/Emacs -Q

Describe function: python-shell [No match]
Dan Jaouen
  • 787
  • 1
  • 8
  • 21
  • 1
    What about `py-shell`? That's the command in XEmacs 21.5; maybe it has changed to this name in GNU Emacs as well. – celtschk Jan 14 '12 at 22:31
  • Nope, when I try to tab complete "M-x py...", I see "python-mode" as the only completion. – Dan Jaouen Jan 14 '12 at 22:35
  • As you noted, if python-mode is not loaded, the py-shell function won't be available. You can use an autoload in your .emacs instead of explicitly loading the mode `(autoload 'py-shell "python-mode" "Python shell." t)` – dave jones Feb 02 '12 at 18:26
  • Do you have `(package-initialize)` after `(add-to-list 'package-archives ...)`? It looks like you need it to load the packages. http://stackoverflow.com/questions/7287947/adding-marmalade-as-package-source / http://stackoverflow.com/questions/3550899/whats-the-magic-behind-the-elpa – tkf Feb 07 '12 at 23:17
  • @DanJaouen, can you please add your solution as an answer and mark it correct, or mark Shantanu's answer? – Mirzhan Irkegulov Apr 15 '12 at 08:01

1 Answers1

23

It seems like you only solved the python-mode issue. As to M-x-python-shell you can also get this by doing M-x-run-python. If it says directory not found its because the the python variable is not pointing to the correct path. So do C-h-f run-python then it will tell you that run-python's value is python-shell-interpreter. So then point it to python.exe in your python folder.

add this to your .emacs file

(setq python-shell-interpreter "path to python.exe")

Then like in emacs 23 you can do C-c-C-c to run a .py file.

edit-the reason i have all of this here even though you may already of known this is because i didnt realize that emacs24 changed the python value for run-python for a while and this is how i fixed it. :D

Shantanu
  • 504
  • 5
  • 15