Daniel Gopar edited this page Dec 27, 2017 · 15 revisions

FAQ

Q: I get a Python error when using Elpy, what can I do?

A: This means the Elpy backend got an error. You can get the full traceback using M-: (elpy-rpc "get_traceback") and see if that provides further information.

If you are using Rope, make sure you have version 0.9.4 installed.

Q: Should I use Rope or Jedi?

A: This is mostly a matter of personal taste.

Rope really is a refactoring library and only provides code completion and introspection as a side effect. This means it tends to be a bit more strict about code formatting, but knows more about the code, too.

Jedi is a dedicated code completion and introspection library, making it very suitable for the task but sometimes providing fewer results.

I found Rope to give slightly more complete completion results, while Jedi was faster, especially for larger projects. Your personal experience can vary. There is no reason not to try both and see which works better for you.

Jedi can work with the new xref feature of Emacs; Rope cannot.

Q: Why do I get some weird errors about functions not defined?

A: Make sure you are using the python.el that comes with Emacs 24, and not python-mode.el or other such Python modes.

Q: Can I tell elpy not to load one of the minor modes it enables by default?

A: You can simply remove the appropriate symbol from elpy-modules.

Q: How do I make Elpy work well with org-mode?

A: You can try the following customization by @mankoff:

(setq python-shell-interpreter "ipython"
      python-shell-interpreter-args "--pylab=osx --pdb --nosep --classic"
      python-shell-prompt-regexp ">>> "
      python-shell-prompt-output-regexp ""
      python-shell-completion-setup-code "from IPython.core.completerlib import module_completion"
      python-shell-completion-module-string-code "';'.join(module_completion('''%s'''))\n"
      python-shell-completion-string-code "';'.join(get_ipython().Completer.all_completions('''%s'''))\n"
      )

See #191 for a discussion and background.

Q: Can I get documentation as pop-ups next to the completion pop-up?

A: Not by default with company-mode, but there’s expez’ excellent company-quickhelp package you can install for this feature. It’s available from MELPA.

Q: How to solve company, yasnippet conflicts?

A: Add this snippet to your emacs configuration to avoid that.

(defun company-yasnippet-or-completion ()
  "Solve company yasnippet conflicts."
  (interactive)
  (let ((yas-fallback-behavior
         (apply 'company-complete-common nil)))
    (yas-expand)))

(add-hook 'company-mode-hook
          (lambda ()
            (substitute-key-definition
             'company-complete-common
             'company-yasnippet-or-completion
             company-active-map)))

Q: Do I have to install all these packages every time?

A: Installing them all in the same virtualenv is the easiest way to do this. There are a few other options, though. You can install jedi etc. globally (or as a user) and use virtualenvwrapper's togglesitepackages to include globally installed packages in your virtualenv. Or you can install them in a separate virtualenv and set PYTHONPATH to include that virtualenv.

Q: How do I install development version of elpy?

A: Remove existing elpy if you already installed it.

rm -rf ~/.emacs.d/elpa/elpy*

Install dependencies

(package-install 'company)
(package-install 'yasnippet)
(package-install 'pyvenv)
(package-install 'highlight-indentation)
(package-install 'find-file-in-project)
(package-install 's)

Get latest code from github

mkdir ~/Projects
cd ~/Projects
git clone https://github.com/jorgenschaefer/elpy

Add the following to your ~/.emacs.d/init.el or ~/.emacs:

(add-to-list 'load-path "~/Projects/elpy")
(load "elpy" nil t)
(elpy-enable)

To update, run git pull --rebase, M-x load-library RET elpy RET and M-x elpy-rpc-reload.

Q: How do I use pdb with Elpy?

A: By default the command when running M-x pdb is incorrect. In order for it to successfully use your python version (whether virtualenv or system) you need to override the following variable like so:

(setq gud-pdb-command-name "python -m pdb")
Clone this wiki locally
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.