%matplotlib inline syntax error

来源:互联网 发布:苹果mac回收 编辑:程序博客网 时间:2024/06/05 11:42

http://stackoverflow.com/questions/35595766/matplotlib-line-magic-causes-syntaxerror-in-python-script

Line magics are only supported by the IPython command line. You cannot use it inside a script like this because it is not correct Python syntax.

If you want to do this from a script you have to get access to the IPython API and then call the run_line_magic function.

Instead of %matplotlib inline, you will have to do something like this in your script:

from IPython import get_ipythonget_ipython().run_line_magic('matplotlib', 'inline')
10down vote

Line magics are only supported by the IPython command line. You cannot use it inside a script like this because it is not correct Python syntax.

If you want to do this from a script you have to get access to the IPython API and then call the run_line_magic function.

Instead of %matplotlib inline, you will have to do something like this in your script:

from IPython import get_ipythonget_ipython().run_line_magic('matplotlib', 'inline')
0 0
原创粉丝点击