0

I am using the terminal in jupyter and am trying to plot with matplotlib. I need to plot inline and so i use %matplotlib inline but i am getting the following error:

>>> %matplotlib inline
  File "<stdin>", line 1
    %matplotlib inline
    ^
SyntaxError: invalid syntax

Why am i getting this error? Is it because it is a terminal and not jupyter notebook type environment? I had tried the same code in jupyter notebook and it did not return any errors.

Slartibartfast
  • 1,058
  • 4
  • 26
  • 60

2 Answers2

1

You should run ipython instead of python in the Jupyter terminal. Then you can execute any magic command.

  • I tried running ipython and got this error: `UnknownBackend: No event loop integration for 'inline'. Supported event loops are: qt, qt4, qt5, gtk, gtk2, gtk3, tk, wx, p yglet, glut, osx` – Slartibartfast Jan 05 '20 at 15:58
  • 1
    Try to find solution in: https://stackoverflow.com/questions/49347477/unknownbackend-no-event-loop-integration-for-uinline-when-enable-inline-matpl and https://stackoverflow.com/questions/42616768/matplotlib-inline-doesnt-work-on-ipython-and-jupyter-console – Christos Sevastiadis Jan 05 '20 at 18:15
0

trying using 'exec(%matplotlib inline)'. Works for me on python3.6