Emacs python-mode
Asked Answered
H

6

8

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...!

Huttan answered 18/5, 2012 at 0:53 Comment(0)
W
8

(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:

Wreathe answered 18/5, 2012 at 1:36 Comment(1)
I gave a look to it, very interesting and informative BTW, but i couldn't get what i was looking for. There r a lot tutorials in some nice blogs to set it up, but all of them are pretty out of date, and it doesn't work well with actual version of the python-mode. Thank u anyway, @phils!Huttan
B
2

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

Bani answered 30/9, 2012 at 19:29 Comment(0)
P
2

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.

Peden answered 18/8, 2013 at 20:59 Comment(0)
U
1

Among advanced features of the python-mode I'm only using

(add-hook 'python-mode-hook (lambda ()
    (define-key python-mode-map (kbd "C-c |")
    'py-execute-region-ipython)))

send region to ipython with C-c |.

Utter answered 7/6, 2012 at 12:15 Comment(0)
P
1

I can wholeheartedly recommend anaconda-mode. It gives you auto completion, documentation lookup, jump to source++. Together with pyflakes, flymake, auto-complete-mode and projectile, it makes Emacs a great Python development environment.

It's easy to set up too, you can start out with these two lines only: (add-hook 'python-mode-hook 'anaconda-mode) (add-hook 'python-mode-hook 'ac-anaconda-setup)

Paleozoology answered 12/4, 2015 at 17:47 Comment(0)
O
0

I suggest use other python-el , such as

https://github.com/fgallina/python.el

Onehorse answered 18/8, 2013 at 15:26 Comment(1)
AFAIK this isn't backward compatible with Emacs versions < 24.3Moravian

© 2022 - 2024 — McMap. All rights reserved.