markvgti
markvgti

Reputation: 4619

Can't get python-mode working in Emacs on Mac OS X

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.

Upvotes: 3

Views: 3066

Answers (4)

Andreas Röhler
Andreas Röhler

Reputation: 4804

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

Upvotes: 0

peixe
peixe

Reputation: 1292

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.. :)

Upvotes: 0

markvgti
markvgti

Reputation: 4619

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.

Upvotes: 1

Ribtoks
Ribtoks

Reputation: 6922

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

Upvotes: 1

Related Questions