pylab没有使用ipython在emacs中加载

时间:2014-10-02 16:32:23

标签: python emacs matplotlib scipy ipython

我在Windows 8中使用Emacs 24.3。使用PowerShell,ipython无问题地加载pylab

PS C:\Users\vince.forgetta> ipython --pylab
Python 3.4.0 (v3.4.0:04f714765c13, Mar 16 2014, 19:25:23) [MSC v.1600 64 bit (AMD64)]
Type "copyright", "credits" or "license" for more information.

IPython 2.2.0 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.
Using matplotlib backend: TkAgg

In [1]: linspace
Out[1]: <function numpy.core.function_base.linspace>

In [2]: plot
Out[2]: <function matplotlib.pyplot.plot>

但是,使用Emacs 24.3我收到以下错误:

Python 3.4.0 (v3.4.0:04f714765c13, Mar 16 2014, 19:25:23) [MSC v.1600 64 bit (AMD64)]
Type "copyright", "credits" or "license" for more information.

IPython 2.2.0 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

In [1]: 
In [2]: 
In [3]: 
In [4]: linspace
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-4-fbab96054277> in <module>()
----> 1 linspace

NameError: name 'linspace' is not defined

In [5]: plot
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-5-88d627f14d84> in <module>()
----> 1 plot

NameError: name 'plot' is not defined

可以通过导入pylab解决:

In [6]: from pylab import *

In [7]: linspace
Out[7]: <function numpy.core.function_base.linspace>

我的.emacs中的Python特定代码是:

;; Python
(setenv "PYTHONUNBUFFERED" "x")
; python-mode
(setq py-install-directory "~/.emacs.d/python-mode.el-6.1.3")
(add-to-list 'load-path py-install-directory)
(require 'python-mode)
; use IPython
(setq-default py-shell-name "ipython")
(setq-default py-which-bufname "IPython")
;; use the wx backend, for both mayavi and matplotlib
(setq py-python-command-args
  '("--gui=wx" "--pylab=wx" "--colors=Linux"))
(setq py-force-py-shell-name-p t)
; switch to the interpreter after executing code
(setq py-shell-switch-buffers-on-execute-p t)
(setq py-switch-buffers-on-execute-p t)
; don't split windows
(setq py-split-windows-on-execute-p nil)
; try to automagically figure out indentation
(setq py-smart-indentation t)

pylab开始使用ipython选项时,--pylab会被导入,但很明显,这似乎并不像我预期的那样有效,或者在那里在某处是一个错误。缓冲区消息不会报告任何错误。

如何在启动pylab缓冲区时自动加载ipython

感谢。

0 个答案:

没有答案