0

I am using PyCharm on my MacBook to code and now I wanted to make a simple plot. When I run the file via the usual 'Run' command (do not know what it is called), it nicely shows my plots, but when I run the file in the Python console (which I find more convenient because you can access your variables) it does not show anything. On the other hand, when I just type it in the Python console afterwards, it does work.

I have read some things about backends and other 'solutions' as I am apparently not the only one with this issue. Mine says macosx and gives the command: "Backend MacOSX is interactive backend. Turning interactive mode on." after running the file in the Python console. I tried changing the backend:

import matplotlib
# matplotlib.use('TkAgg')
import matplotlib.pyplot as plt

but that does not work (no plot pops up). And yes, I use plt.show() after my plotting section :)

I also tried with 'QtAgg' but then I get: "ImportError: Failed to import any qt binding"

Now I am completely new to this backends stuff (I think it has to do with this), so I could really use some clear directions on how I can solve this issue.

Thanks in advance!

  • Check if you have installed the relevant Qt package (just on from the possible Qt backends): https://matplotlib.org/stable/devel/dependencies.html#optional-dependencies – Giacomo Catenazzi Mar 10 '22 at 09:59
  • For a start, you can check which backends are installed and available in your environment with the last code block here: https://stackoverflow.com/a/43015816/8881141 – Mr. T Mar 10 '22 at 10:12

1 Answers1

0

I am not sure we can solve this bug with some adjustment. I think you need to fresh start. I suggest you to start a new clean venv and install a new matplotlib there.