python 在线ide搭建_windows下python IDE的搭建

近几天有时间了,打算好好学习下python的实际应用,又好好鼓捣了下emacs下的python编程环境,至于为什么是emcs,个人习惯,不做解释

0818b9ca8b590ca3270a3433284dd417.png.

长话短说,首先配置emacs的python模式,emacs自带的python模式功能不够强大,自己下载python-mode.el扔到你的加载目录中,并在.emacs中做如下配置

(setq auto-mode-alist (cons '("\\.py$" . python-mode) auto-mode-alist))

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

(setq interpreter-mode-alist (cons '("python" . python-mode)

interpreter-mode-alist))

(setq py-python-command "python")

(autoload 'python-mode "python-mode" "Pythonediting mode." t)

至于作为一个编程环境,自动补全自然是必不可少的了,在网上搜寻了一番,最终选择了rope+pymacs的补全方式.安装步骤如下:

安装方法: python setup.py install

pymacs的安装有点麻烦,我下载的pymacs 0.25,按照网上所述,我在windows命令行下直接python setup.py install提示找不到pymacs.py,查阅了安装说明后发现需要行做make生成pymacs.py和pymacs.el文件,我机器上的是mingw,在windows命令行下直接make会提示IO错误,百思不得其解,折腾一番后,最终在msys下make成功,然后setup.py install即可成功安装.

安装方法 python setup.py install

安装方法  python setup.py install

然后在.emacs中做加载设置,因为pymacs载入较慢,每次启动emacs时都加载的话会很慢,所以我选择在打开python文件时才加载,配置如下:

(eval-after-load "python-mode"

'(progn

(autoload 'pymacs-apply "pymacs")

(autoload 'pymacs-call "pymacs")

(autoload 'pymacs-eval "pymacs" nil t)

(autoload 'pymacs-exec "pymacs" nil t)

(autoload 'pymacs-load "pymacs" nil t)

(require 'pycomplete)

(message "loading ropemacs")

(pymacs-load "ropemacs" "rope-")

(setq ropemacs-enable-autoimport t)

(require 'python-pep8)

(require 'python-pylint)

(add-hook 'before-save-hook 'delete-trailing-whitespace)))

为了得到更好的补全效果,再安装一个更强大的智能提示工具pycomplete,下载

pycomplete.el ,扔到load-path中

再下载  pycomplete.py 扔到PYTHONPATH (比如: c:/python26/Lib/site-packages)

然后(require 'pycomplete)即可,这里我和pymacs的加载写到了一起

最后配置autocomplete,这个是emacs自带的,它的配置是从网上找来的,配置如下

(require 'auto-complete)

(require 'auto-complete-config)

;; (setenv "PYMACS_PYTHON" "python2.7")

(global-auto-complete-mode t)

(setq-default ac-sources '(ac-source-words-in-same-mode-buffers))

(add-hook 'emacs-lisp-mode-hook (lambda () (add-to-list 'ac-sources 'ac-source-symbols)))

(add-hook 'auto-complete-mode-hook (lambda () (add-to-list 'ac-sources 'ac-source-filename)))

(ac-ropemacs-initialize)

(add-hook 'python-mode-hook

(lambda ()

(add-to-list 'ac-source 'ac-source-ropemacs)))

(set-face-background 'ac-candidate-face "lightgray")

(set-face-underline 'ac-candidate-face "darkgray")

(set-face-background 'ac-selection-face "steelblue")

(define-key ac-completing-map "\M-n" 'ac-next)

(define-key ac-completing-map "\M-p" 'ac-previous)

(setq ac-auto-start 2)

(setq ac-dwim t)

(define-key ac-mode-map (kbd "C-TAB") 'auto-complete)

安装yasnippet,下载

https://github.com/capitaomorte/yasnippet

解压扔到load-path, 配置如下

(add-to-list 'load-path

"D:/tools/emacs-24.1.50/site-lisp/yasnippet")

(require 'yasnippet)

(yas/global-mode 1)

最终效果如下

0818b9ca8b590ca3270a3433284dd417.png

参考资料:

http://pedrokroger.com/2010/07/configuring-emacs-as-a-python-ide-2/

http://emacswiki.org/emacs/PythonProgrammingInEmacs

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值