enter image description here

so i have this lab in coursera course, well i tried first at Linux terminal at the first command %matplotlib inline, it doesn't work : ( bash: fg :%matplotlib no such job ), even if I apply it like matplotlib inline or matplotlib also doesn't work, I know those lines like IN[19] show when you write ipython in the terminal so even when I write ipython then %matplotlib inline it doesnt work, also for the command import ipython it doesn't work, since I am already in iypthon how could I import ipython


1 Answer 1


%matplotlib inline is a magic command for IPython that allows you to add plots to the browser interface. It's not for the the terminal.

Sounds like you are using the Python interpreter at the command line, which isn't going to be useful for you as a beginner. Install jupyter notebook and use it instead of the command line interpreter to follow along with your course.

You do need to import IPython into your script (like any other module) if you want to use their functions during your script. This is not the same as installing a dependency from pip where it is downloaded and saved to your python local environment.

  • $\begingroup$ thank you so much, it worked in general but still when i use plot shows this error -------------------------------------------------------------------------- AttributeError Traceback (most recent call last) /home/stealth/.local/lib/python2.7/site-packages/ipykernel/pylab $\endgroup$ Dec 3, 2020 at 3:06
  • $\begingroup$ /backend_inline.pyc in show(close, block) 37 display( 38 figure_manager.canvas.figure, metadata=_fetch_figure_metadata(figure_manager.canvas.figure) 40 ) 41 finally: /home/stealth/.local/lib/python2.7/site-packages/ipykernel/pylab/backend_inline.pyc in _fetch_figure_metadata(fig) 172 """Get some metadata to help with displaying a figure.""" $\endgroup$ Dec 3, 2020 at 3:09
  • $\begingroup$ It looks like you are running this in Python 2.7 - which is quite different to Python 3+ and could be part of the problem. I would suggest looking into Virtual environments and being careful to use the exact Python version your tutor recommends. It also could be that you aren't loading your data correctly too. realpython.com/python-virtual-environments-a-primer $\endgroup$
    – lys
    Dec 3, 2020 at 4:23
  • $\begingroup$ i will check that, thank you so much $\endgroup$ Dec 4, 2020 at 23:13

Not the answer you're looking for? Browse other questions tagged or ask your own question.