Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Emacs python-mode

I'm trying to configure Emacs23.2 to work with python2.7.3, using the package python-mode.el-6.0.7

After adding to my .emacs file these LISP lines, as indicated in the INSTALL instructions,...

(add-to-list 'load-path "PATH/TO/PYTHON-MODE/") 
(setq py-install-directory "PATH/TO/PYTHON-MODE/")
(require 'python-mode)

... I open a file foo.py and until here its all OK: python is recognised, the syntax is highlighted and emacs is working well.

But I got the suspect I'm missing something or doing something wrong... Mainly, because in the python-mode package there is some more stuff to use with python&emacs, like pycomplete, pymacs, etc... which looks like they are not operating together when I open emacs & python.

Does anyone know how to configure this package in a proper way, to get everything together working right?

Any (personal) suggestion is welcome, as I am not a pro with emacs...!

like image 760
peixe Avatar asked May 18 '12 00:05

peixe


People also ask

Is Emacs good for Python?

Emacs for Python Development With elpy. Emacs is ready out of the box to edit Python code. The library file python. el provides python-mode, which enables basic indentation and syntax highlighting support.

How do I 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.


3 Answers

(I imagine someone will provide a better answer, but...)

The documentation for Python support on the EmacsWiki used to be pretty messy, in part because there were two different major modes to choose from, and information for each was all mixed into the same page.

It's clearly been cleaned up a great deal since I first encountered it, so hopefully it's not too confusing, and you'll find what you need at one of the following:

  • http://emacswiki.org/emacs/PythonProgrammingInEmacs
  • http://wikemacs.org/wiki/Python
like image 106
phils Avatar answered Sep 22 '22 21:09

phils


current python-mode.el comes with an extended menu: PyEdit, PyExec etc.

https://launchpad.net/python-mode/+download

See also in section doc commands-python-mode.org resp. commands-python-mode.rst

Remaining questions might be filed in https://answers.launchpad.net/python-mode

like image 35
Andreas Röhler Avatar answered Sep 21 '22 21:09

Andreas Röhler


This are the relevant lines from my init.el:

(setq py-install-directory "~/.emacs.d/site-lisp/python-mode.el-6.1.1")

(add-to-list 'load-path py-install-directory)

(require 'python-mode)

Download the latest version of python-mode from Launchpad and tell Emacs in your init.el where to find it. (see above)

If your Major-Mode says Py you are using pyhon-mode.el, if it says Python, then you are using the built-in python.el mode.

For Auto-completion you should try Jedi, this is a very nice completion library for python.

You can customize python-mode via the very comprehensive menu entries or via

M-x customize-mode.

like image 22
martin Avatar answered Sep 23 '22 21:09

martin