Python 3 with Emacs

8.6k Views Asked by At

Is there anything that should be done to make GNU Emacs 23.2 work well with Python 3?

How would an ideal environment for development with Python 3 in Emacs look like?

Is there any documentation about using ropemacs with Python 3?

Should I add Python 3's site-packages directory to the python path?

Will following the instructions here (for python-mode.el) or setting python-python-command to python3 for python.el affect pymacs or ropemacs?

EDIT: From GNU Emacs 23.2's python.el (authored by Dave Love):

;; Fixme: This doesn't support (the nascent) Python 3

How well does python-mode.el support it?

3

There are 3 best solutions below

1
On BEST ANSWER

From Loveshack python.el:

There is support for editing both Python 2 and Python 3 languages, and using interpreters for either version to run the emacs.py module in inferior processes.

From README file for Pymacs (notes for 0.24 beta 2):

The biggest change is Python 3 support. This required new installation mechanics, and a Python pre-processor written for the circumstance (named pppp).

It seems that ropemacs will soon support py3k as well.

Also I hope to see ports of ropemode and ropemacs/ropevim to py3k; they should be a lot easier to do, since it involves mostly syntax fixes, AFAICT.

CEDET also seems to support Python (3?) at this point.

Given checkers that support py3k, flymake will work with emacs, too. Auto complete mode can be made to support py3k as well, provided its sources work with it.

0
On

ropemacs is specifically for refactoring python code in Emacs. pymacs is sort of like an API for communication between EMACS Lisp and Python.

ropemacs uses pymacs to allow for giving refactoring capabilities in Emacs.

The instructions are for directly developing in Python using Emacs. If you are looking to directly develop with Python in Emacs, I would recommend directly using the following link: https://launchpad.net/python-mode

It puts Emacs in python mode for development. You will need to apply the patch in the instructions link since there are still bugs with using the python-mode directly in Emacs. Hope that helps.

0
On

Both Python-modes support Python3

If python3 is not your default Python-shell

M-x python3(VERSION) will open an interactive shell at python-mode.el

When a shebang shows python3, it's recognised.

Maybe set Emacs Python defaults

py-shell-name at python-mode.el

python-shell-interpreter in Emacs-24.3 python.el

python-python-command in previous python.el

If python-mode.el is not available, get it here:

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