Reputation: 47441
I am using Ubuntu 10.10 (Maverick Meerkat). I have downloaded python-mode.el
from Launchpad and placed it in emacs.d/plugins/
.
Now how do I install python-mode.el
?
Upvotes: 13
Views: 9666
Reputation: 7696
In emacs 25, you can install python mode using melpa, so just add this to your .emacs file:
(require 'package)
(add-to-list 'package-archives
'("melpa-stable" . "https://stable.melpa.org/packages/"))
Reload the file, then type,
Alt+x list-packages
Move to the package you want,
python-mode
Then hit "enter", and in the new buffer that opens move to Install
and press enter.
This causes python-mode to be installed in ~/.emacs.d/elpa
Now in a new buffer with python-mode
on, write your code and type C-u C-c C-c
to evaluate and display output.
Upvotes: 2
Reputation: 13487
I'd suggest cloning the latest snapshot:
cd ~/.emacs.d/site-lisp/python-mode
bzr branch lp:python-mode
Then add to .emacs
:
(add-to-list 'load-path "~/.emacs.d/site-lisp/python-mode")
(setq py-install-directory "~/.emacs.d/site-lisp/python-mode")
(require 'python-mode)
You can later update the to the latest version with:
bzr update
But don't forget to re-compile:
(byte-recompile-directory (expand-file-name "~/.emacs.d/site-lisp/python-mode") 0)
Upvotes: 3
Reputation: 834
I find it more convenient to have the appropriate editing mode auto-load based on the type of file edited. There are lots of ways to do this, but I usually add an entry to autoload-alist:
(and (library-loadable-p "python-mode")
(setq auto-mode-alist (append '(
("\\.py\\'" . python-mode)
)
auto-mode-alist)))
I have a long list of these for the various modes I like to use. It fails silently if python-mode (or any other mode) is not installed. If I'm running on an ISP sever that doesn't have a mode installed, I add ~/lib/elisp to the load-path and put the missing .el files in there.
library-loadable-p came from a friend and simply tests whether the file is somewhere in the load path:
(defun library-loadable-p (lib &optional nosuffix)
"Return t if library LIB is found in load-path.
Optional NOSUFFIX means don't try appending standard .elc and .el suffixes."
(let ((path load-path)
elt)
(catch 'lib-found
(while (car path)
(setq elt (car path))
(and
(if nosuffix
(file-exists-p (concat elt "/" lib))
(or (file-exists-p (concat elt "/" lib ".elc"))
(file-exists-p (concat elt "/" lib ".el"))
(file-exists-p (concat elt "/" lib))))
(throw 'lib-found t))
(setq path (cdr path))))))
Upvotes: 3
Reputation: 4637
Try this
(add-to-list 'load-path "~/.emacs.d/plugins")
(require 'python-mode)
Upvotes: 9