使用matplotlib内联的Jupyter QtConsole语法错误

时间:2016-03-31 10:48:47

标签: python python-2.7 jupyter

好的我现在已经遇到这个问题一段时间了,我很茫然。

我正在运行Jupyter QtConsole并尝试运行python脚本。

from __future__ import division
from ipywidgets import *
import numpy as np
import matplotlib.pyplot as p
%matplotlib inline

QtConsole不断给我一个错误:

run test.py
  File "/home/Bob/Desktop/test.py", line 5
    %matplotlib inline
    ^
SyntaxError: invalid syntax

从我读到的这是Ipython特定的代码,它应该在Jupyter QtConsole中工作,我通过转到终端并键入:

bob@bob-laptop:~/Desktop$ jupyter qtconsole

它在终端中给出了这个,但随后加载了qtconsole。

/usr/local/lib/python2.7/dist-packages/IPython/paths.py:62: UserWarning: IPython dir '/home/bob/.ipython' is not a writable location, using a temp directory.
  " using a temp directory.".format(ipdir))
Bus::open: Can not get ibus-daemon's address. 
IBusInputContext::createInputContext: no connection to ibus-daemon 
/usr/local/lib/python2.7/dist-packages/IPython/paths.py:62: UserWarning: IPython dir '/home/bob/.ipython' is not a writable location, using a temp directory.
  " using a temp directory.".format(ipdir))

请帮助。

1 个答案:

答案 0 :(得分:0)

启动qtconsole后,在控制台上键入%matplotlib inline,并在所有图表内联后显示。

希望这有帮助。