* Using Python with Emacs [#ubab6009]
[[Back>PythonForScience]]
#contents
** Introduction [#rdea2d00]
In this page, I will explain ''my'' emacs environment for programing and interactive session with Python. I put emphasis on ''my'' because this may not be the most elegant solution (and probably it isn't). The effectiveness of a human interface depends a lot on the user's preference. Therefore, the example shown here strongly reflects my personal preferences. You may want to change details of the behavior. You can do so but you have to know a bit about Emacs Lisp. Since I don't have a time to explain Emacs Lisp here, I will just refer you to two nice documents for learning Emacs Lisp, [[An Introduction to Programming in Emacs Lisp>http://www.gnu.org/software/emacs/emacs-lisp-intro/]] and [[GNU Emacs Lisp Reference Manual>http://www.gnu.org/software/emacs/manual/elisp.html]].

** My computer environment [#y460d76c]
Before going into the details of the emacs setting, I will list my computer environment as a reference.

|Hardware| PC (Sony VAIO type Z)|
|OS|Ubuntu 9.04 (x86-64)|
|OS|Ubuntu 9.10 (x86-64)|

** Additional packages [#qd13cce5]
In addition to Emacs, you need to install several packages.
I took most of the information from [[here>http://www.emacswiki.org/emacs/PythonMode]].

- python-mode.el -- This is the main guy. It defines a major mode for python editing and interactive execution. We will add some tweaks to this mode later. It is a part of the python distribution. You can download it also from [[https://launchpad.net/python-mode]]. On Ubuntu, it is in the '''python-mode''' package.
- IPython -- [[IPython>http://ipython.scipy.org/moin/]] is a better interactive shell for Python. It has a lot more functionalities than the standard python shell. We will use IPython as a Python shell in Emacs. You should check these [[video tutorials>http://showmedo.com/videotutorials/series?name=CnluURUTV]] for IPython as these are damn good. On Ubuntu, you can just download and install ipython package.
- Folding-mode -- Folding mode is a minor mode to allow folding a region of Emacs buffer. I used this to implement cells. You can get more information about folding-mode from [[here>http://www.emacswiki.org/emacs-en/FoldingMode]]
- ropemacs -- rope pymacs
- pylint -- epylint
- ropemacs -- Rope is a refactoring library for Python. ropemacs enables you to use rope functionalities from emacs. ropemacs can be obtained from [[http://rope.sourceforge.net/ropemacs.html]]. You also need [[rope>http://rope.sf.net/]] and [[pymacs>http://pymacs.progiciels-bpi.ca/pymacs.html]] to use ropemacs.
- pylint -- pylint is a grammar checker for python. To use it from emacs, you need epylint script, which may be provided with pylint. If not, get it from [[here>http://www.emacswiki.org/emacs/PythonMode#toc8]].

** .emacs file [#d98b50a0]
Once you have installed the above packages, edit your .emacs file.~
Here is an example of [[.emacs>https://granite.phys.s.u-tokyo.ac.jp/wiki/Lab/index.php?plugin=attach&pcmd=open&file=dotemacs&refer=EmacsPython]] file. You can merge this file into your .emacs file. Please read the comments in the file to see what is going on.


トップ   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS