您的位置:首页 > 编程语言 > Python开发

Emacs+Python(非默认模式)快速配置

2014-02-23 20:39 543 查看
Emacs自己带有Python模式,可以直接在Emacs内部运行Python,很方便。但是据说做得不是很好(来源:将Emacs作为Python集成开发环境 点击打开链接)。

上面这个是08年写的,比较老了。我试一下,顺便更新。其提供的下载链接现在也已经转移了。新的下载链接是:An Emacs mode for editing Python code 点击打开链接

下载之后,解压,cd进去

cd /home/rare/桌面/python-mode.el-6.1.3(这个改成你的路径)

chmod +x byte-compile-directory.sh

sudo ./byte-compile-directory.sh

这样编译完之后:

1.把python-mode.el-6.1.3放到主文件夹, 然后终端里输入

sudo cp -r ~/python-mode.el-6.1.3 /usr/share/emacs/site-lisp

2.打开.emacs,在文件尾部加入以下语句(原封不动拷过去):

(add-to-list 'load-path "/usr/share/emacs/site-lisp/python-mode.el-6.1.3") 

(setq py-install-directory "/usr/share/emacs/site-lisp/python-mode.el-6.1.3")

(require 'python-mode)

3.重新打开Emacs,效果如下:



特别值得一提的是在Python菜单中,Interpreter比默认模式多了很多,各种Python版本都可以选择~~~

特别提醒,一定要编译过了才能做以上这几步

=================================附录==========================

另附一个把Emacs做成IDE的,回头再来研究: Emacs中打造强大的Python IDE 点击打开链接

我的.emacs配置文件(矩阵主题+Matlab+Python(非默认模式)):

(add-to-list 'load-path "~/.emacs.d/")
(require 'color-theme)
(color-theme-initialize)
(color-theme-matrix)

(add-to-list 'load-path "/usr/share/emacs/site-lisp/matlab-emacs")
(load-library "matlab-load")
(custom-set-variables
'(matlab-shell-command-switches '("-nodesktop -nosplash")))

(add-to-list 'load-path "/usr/share/emacs/site-lisp/python-mode.el-6.1.3")
(setq py-install-directory "/usr/share/emacs/site-lisp/python-mode.el-6.1.3")
(require 'python-mode)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  python emacs ubuntu