我想在一个文件夹中有一个批处理文件 python
脚本。批处理文件应该调用脚本 IPython
并绘制内嵌/嵌入的数字。虽然有很多关于这方面的信息,但我没有让这个工作。
- 如何运行
python
脚本用IPython
,显示嵌入的情节? - 我需要使用吗?
pylab
或者我可以导入matplotlib.pyplot
在脚本中? - 我是否必须改编脚本中的其他内容?
- 是
%pylab inline
/%matplotlib inline
是否使用?
后面的命令给出了
In [1]: %pylab inline
UsageError: Invalid GUI request u'inline', valid ones are:[None, 'osx', 'qt4',
'glut', 'gtk3', 'pyglet', 'wx', 'none', 'qt', 'gtk', 'tk']
In [2]: %matplotlib inline
UsageError: Invalid GUI request u'inline', valid ones are: [None, 'osx', 'qt4',
'glut', 'gtk3', 'pyglet', 'wx', 'none', 'qt', 'gtk', 'tk']`
到目前为止我尝试了以下(不幸)
ipython --pylab=inline example_plots.py
给我以下并退出
E:\CD\package\bin>ipython --pylab=inline example_plots.py
WARNING: 'inline' not available as pylab backend, using 'auto' instead.
WARNING: 'inline' not available as pylab backend, using 'auto' instead.
或从控制台运行,但像往常一样弹出数字(并立即关闭):
E:\CD\package\bin>ipython --pylab=inline example_plots.py
WARNING: 'inline' not available as pylab backend, using 'auto' instead.
WARNING: 'inline' not available as pylab backend, using 'auto' instead.
Using matplotlib backend: Qt4Agg
# runs python script as usual (not inline)
以下 如何使IPython笔记本matplotlib内联
使用批处理文件(和控制台一样):
ipython notebook --pylab inline example_plots.py
2014-01-26 17:52:10.101 [NotebookApp] Using existing profile dir: u'C:\\Users\\Robert\\.ipython\\profile_default'
2014-01-26 17:52:10.111 [NotebookApp] Using MathJax from CDN: http://cdn.mathjax.org/mathjax/latest/MathJax.js
2014-01-26 17:52:10.127 [NotebookApp] Serving notebooks from local directory: E:\CD\package\bin
2014-01-26 17:52:10.128 [NotebookApp] The IPython Notebook is running at: http://127.0.0.1:8888/
2014-01-26 17:52:10.128 [NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
打开一个空的笔记本就可以了。
我还应该尝试什么?
Python 2.7.5 (default, May 15 2013, 22:43:36) [MSC v.1500 32 bit (Intel)]
IPython 1.1.0 -- An enhanced Interactive Python.