Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python Shell in Emacs 24?

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] 
like image 813
Dan Jaouen Avatar asked Jan 14 '12 22:01

Dan Jaouen


People also ask

Can you run Python in Emacs?

Once you open your python file in Emacs, you will need to start the python process with: M-x run-python or C-c C-p , which creates an inferior python shell buffer. This buffer will be created by a horizontal split, and the active buffer will be the one containing the python file.

What is Emacs ELPY?

Elpy is an Emacs package to bring powerful Python editing to Emacs. It combines and configures a number of other packages, both written in Emacs Lisp as well as Python. Elpy is fully documented at Readthedocs.

What is Emacs Python?

Emacs (the major flavors being GnuEmacs and XEmacs) is a text editor which come with good support for writing Python code. Each has its strengths and weaknesses, but in general either provide very nice environments for the Python programmer.


1 Answers

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

like image 150
Shantanu Avatar answered Sep 25 '22 02:09

Shantanu