Emacs python-mode

2019-03-16 07:14发布

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

6条回答
男人必须洒脱
2楼-- · 2019-03-16 07:35

I suggest use other python-el , such as

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

查看更多
甜甜的少女心
3楼-- · 2019-03-16 07:36

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

查看更多
forever°为你锁心
4楼-- · 2019-03-16 07:37

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

查看更多
Viruses.
5楼-- · 2019-03-16 07:39

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)

查看更多
ゆ 、 Hurt°
6楼-- · 2019-03-16 07:54

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.

查看更多
Melony?
7楼-- · 2019-03-16 07:54

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

查看更多
登录 后发表回答