emacs and python using Rope

01.26.13 | 1 Comment

NOTE: After playing with this configuration for a while, I discovered Jedi. Jedi is an alternative to rope, but the setup is easier and the operation is much quicker/smoother. See this post for more details.

A lot has been written already on how to configure emacs to make it a super powered Python IDE. Here are just some of the sources I have found:

So, to add to the confusion and noise, here are my notes as I evolve my own Python setup.

  1. Install the pyflakes python library:
    1. easy_install.exe pyflakes
    2. Note that the emacs is installed below.
  2. Install rope python library. I like to use easy_install:
    easy_install.exe rope
  3. Install ropemode python library:
    easy_install.exe ropemode
  4. Install pymacs library. This one is a little trickier because it is both a Python and emacs library
    1. Download the zip file.
    2. Unzip it.
    3. Make sure both python.exe and emacs.exe can be found using the PATH.
    4. Run make check
    5. Run make install
    6. Install the emacs side using the ELPA package manger below.
    7. See here for more install information.
  5. For the emacs modules, most can be found in the repositories:
    1. M-x package-list-packages RET
    2. Now search for pymacs, flymake, flymake-python-pyflakes, pyflakes
    3. Mark each one with “i”
    4. Then install them with “x”
  6. You will have to install ropemacs manually.
    1. Download it from here.
    2. Un-tar the archive.
    3. In the new directory, run python setup.py install
  7. Update your .emacs file:
    (autoload 'pymacs-apply "pymacs")
    (autoload 'pymacs-call "pymacs")
    (autoload 'pymacs-eval "pymacs" nil t)
    (autoload 'pymacs-exec "pymacs" nil t)
    (autoload 'pymacs-load "pymacs" nil t)
    (defun load-ropemacs ()
    "Load pymacs and ropemacs"
    (require 'pymacs)
    (pymacs-load "ropemacs" "rope-")
    ;; Automatically save project python buffers before refactorings
    ;;(setq ropemacs-confirm-saving 'nil)
    ;;Flymake errors in Mini-buffer
    (defun my-flymake-show-help ()
      (when (get-char-property (point) 'flymake-overlay)
       (let ((help (get-char-property (point) 'help-echo)))
        (if help (message "%s" help)))))
    (add-hook 'post-command-hook 'my-flymake-show-help)
    (add-hook 'python-mode-hook
    (lambda ()
    (add-to-list 'ac-sources 'ac-source-ropemacs)
    (require 'flymake-python-pyflakes)
  8. If you get a “Key Sequence” error. Read this.
    1. In my case Bookmark+ was using C-x p n. This was greedy in their case as they bound 4 different key sequences to the same command.
    2. In order to free up C-x p n, I had to add the following command after loading Bookmark+: (global-unset-key “\C-xpn”)
  9. Have a look at the ropemacs readme to get an idea for the new tools it offers.
  10. If you have trouble getting pyflakes to run, have a look here and especially here.
  11. Making things faster
    1. Loading ropemacs through pymacs is very slow – no solution yet
    2. Running Pyflakes on every save is slow – Use python-check instead TODO or this
    3. rope can be very slow
      1. TODO
      2. https://groups.google.com/forum/?fromgroups=#!searchin/rope-dev/ropevim:$20why$20so$20slow$20when$20saving/rope-dev/o0OWbyghjgA/9oVGodHjSPIJ
  12. TODO: What about pylint?

See Also:

  • http://www.saltycrane.com/blog/2010/05/my-emacs-python-environment/

1 Comment

have your say

Add your comment below, or trackback from your own site. Subscribe to these comments.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

You must be logged in to post a comment.