Code navigation, documentation lookup and completion for Python.
This mode support 2.6, 2.7, 3.3 and 3.4 Python versions and provide following features
- context-sensitive code completion
- jump to definitions
- find references
- view documentation
- virtual environment
- eldoc mode
All you need is install the package from Melpa:
M-x package-install RET anaconda-mode RET
vendor
directory used to build Melpa package only. If you setup
from git you can't use git submodules for dependency resolution.
Clone this repository somewhere, add it to you load-path
and do
following command from project root:
pip install -r requirements.txt -t .
Anaconda mode comes with anaconda_mode.py
server. This server
allow you to use jedi package over jsonrpc api. Server choice first
available port starting from 24970. If no host was specified loopback
interface will be used. Anaconda mode will run this server
automatically on first call of any anaconda-mode command. Anaconda
mode detect active virtual environment through value of
python-shell-virtualenv-path
variable defined in python.el
library. When you set it to actual virtualenv path next anaconda-mode
command you call will restart server process in proper environment
before performing this call. This allow anaconda processing virtual
environment site-packages with minimum number of actions from your
side. I strongly recommended you to use pyenv-mode or similar
package to hold python-shell-virtualenv-path
in actual state.
It's possible to use anaconda-mode on remote server when you connect
to it using tramp. Setup process differs from local usage. You need
to login on remote machine and install anaconda-mode server. You can
download it directly from Melpa and unpack it to some directory. If
you use virtual environment on remote server then you need to activate
it before we continue. Now run anaconda_mode.py
from shell:
. venv/bin/activate python anaconda_mode.py 0.0.0.0
To tell anaconda-mode to connect to that server you need to run following command:
M-x anaconda-mode-remote
It will ask you to enter host and port information for remote server.
In case of vagrant you can specify 127.0.0.1
as host part. To get
proper completion you need to open your files with tramp addresses
even for vagrant setup. This caused because of different relative
paths on your local machine and inside vagrant. To stop this behavior
and enable anaconda_mode.py
server starts locally run command
below:
M-x anaconda-mode-local
Here are interactive commands available with anaconda-mode
Keybinding | Description |
---|---|
M-. | anaconda-mode-goto-definitions |
M-* | anaconda-nav-pop-marker |
M-? | anaconda-mode-view-doc |
M-r | anaconda-mode-usages |
If goto definitions, assignments or usages cause multiple candidates
you'll see advanced anaconda navigator buffer. You can automatically
enable anaconda-mode
in all python buffers with following code in
your configuration
(add-hook 'python-mode-hook 'anaconda-mode)
anaconda-mode
provide document function to eldoc-mode
. All
you need is enable eldoc-mode
in addition to previous setup.
(add-hook 'python-mode-hook 'eldoc-mode)
If you're using proxy server, you have to make sure that the proxy is not used for communication with anaconda-mode:
export no_proxy="localhost,127.0.0.1"
Are very welcome. But any significant change has to be accompanied with tests, both for Emacs Lisp and Python code. To run the test suite, call:
tox
- Dmitry Gutov @dgutov
- Bo Lin @sadboy
- Vasilij Schneidermann @wasamasa
- Fredrik Bergroth @fbergroth
- Fabio Corneti @fabiocorneti