3

I can't get python-mode working in Emacs on Mac OS X (I am a relative OS X newbie & not exactly an Elisp expert).

I installed the Emacs from http://emacsformacosx.com/. The version is reported as "GNU Emacs 23.3.1 (x86_64-apple-darwin, NS apple-appkit-1038.36) of 2011-12-13 on bob.porkrind.org"

I have the following lines in my ~/.emacs file:

(add-to-list 'load-path "/Applications/Emacs.app/Contents/Resources/lisp/progmodes")
(setq auto-mode-alist
      (cons '("\\.py$" . python-mode) auto-mode-alist))
(setq interpreter-mode-alist
      (cons '("python" . python-mode) interpreter-mode-alist))
(autoload 'python-mode "python-mode" "Python Editing Mode" t)

But whenever I load up a file with the .py extension, the mode still remains Fundamental.

4 Answers 4

1

Try to add this to your .emacs file (also, set path to your python-mode. mine is in .emacs.d/ folder) before your python-lisp-includes code

(add-to-list 'load-path "~/.emacs.d/python-mode")
(require 'python-mode)

Look for files here http://www.emacswiki.org/emacs/?action=browse;oldid=PythonMode;id=PythonProgrammingInEmacs

Sign up to request clarification or add additional context in comments.

2 Comments

There's no python-mode.(el|elc) in my ~/.emacs.d/ directory.
@markvgti than you can look for it in the internet.. Updated the answer.
1

Ok, so here's how I got python-mode (python-mode.el, not python.elc) working on my install:

  1. Downloaded python-mode.el-6.0.8.tar.gz to my ~/Downloads folder.
  2. pushd /Emacs/directory/with/other/.el/files (this directory was actually /Applications/Emacs.app/Contents/Resources/lisp/progmodes/ on my machine)
  3. tar -xzf ~/Downloads/python-mode.el-6.0.8.tar.gz
  4. popd
  5. Then added the following lines to my ~/.emacs file (replacing all other references to python or python-mode):

    (add-to-list 'load-path "/Emacs/directory/with/other/.el/files/python-mode.el-6.0.8")
    (setq py-install-directory "/Emacs/directory/with/other/.el/files/python-mode.el-6.0.8")
    (require 'python-mode)
    

The only remaining issue now — which was created by the successful install & activation of python-mode — is that an unnecessary buffer also gets created with an interactive invocation of the Python interpreter.

Thanks to @Ribtoks for the link that got me started along the correct path.

Comments

0

If your load path is right, could you try adding this line right after it?

(autoload 'python-mode "python-mode" "Python Mode." t)

I'm using emacs from Linux. Dont know if this might be the difference with Aquamacs. Anyway, there's a page for configuring Aquamacs with Python mode. Didnt read it, but maybe it should be worth reading for any related tip.. :)

3 Comments

Didn't work. Getting File mode specification error: (file-error "Cannot open load file" "python-mode") There is a python.elc in the path mentioned earlier (/Applications/Emacs.app/Contents/Resources/lisp/progmodes)
Does the path added using 'load-path have to point to the actual .el|.elc file, or just the directory in which the relevant .el|.elc file is contained?
It should point to the file. For me its works like this, loading directly the file... (load "~/.emacs.d/py_mode/6.0.6python-mode.el") (See edits on the answer)
0

auto-creating of an python-shell instance should be fixed in current trunk, resp. latest release

if not, please file a report at https://bugs.launchpad.net/python-mode

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.