%matplotlib inline syntax error

xiaoxiao2021-02-27  571

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_ipython get_ipython().run_line_magic('matplotlib', 'inline') 10 down 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_ipython get_ipython().run_line_magic('matplotlib', 'inline')
转载请注明原文地址: https://www.6miu.com/read-2172.html

最新回复(0)