0

I run this script in a Jupyter notebook:

import matplotlib.pyplot as plt
plt.plot(range(10))

I get a nice plot as an output. I run this debug.py from terminal:

import matplotlib.pyplot as plt
plt.plot(range(10))
plt.show()

./debug.py doesn't give a plot. My cursor changes shape, it becomes a cross pointer, but I don't get any plot, and I don't get back my terminal prompt.

Following the recommendation given in this answer, I run in a local python3 shell this:

>>> import matplotlib
>>> print(matplotlib.rcParams['backend'])

The output is TkAgg, as it should be, based on the answer to the aforementioned question.

Why I don't get a matplotlib window then?

zabop
  • 6,750
  • 3
  • 39
  • 84
  • If debug.py is this: import matplotlib.pyplot as plt print(matplotlib.rcParams['backend']) and I run it, I don't get an output, just the changed-shape cursor. – zabop Aug 21 '18 at 14:08
  • `python3 debug.py` – Stop harming Monica Aug 21 '18 at 14:10
  • @Goyo, with this debug.py: `import matplotlib print(matplotlib.rcParams['backend'])` I get TkAgg as output. With debug.py being this: `import matplotlib.pyplot as plt plt.plot([1,2,3,4]) plt.ylabel('some numbers') plt.show()` I get a window, as I wanted. Maybe I need to run my scripts python3 myscript.py, rather than ./myscript.py, though I dont understand why that'd be the case. – zabop Aug 21 '18 at 14:12
  • Because your shell does not know that `debug.py` is intended to be run by python3. Why should it? – Stop harming Monica Aug 21 '18 at 14:24

0 Answers0