I would like to interact with the plots. But I got the error for %matplotlib qt :ImportError: Cannot load backend 'Qt5Agg' which requires the 'qt5' interactive framework, as 'headless' is currently running
I would like to interact with the plots. But I got the error for %matplotlib qt :ImportError: Cannot load backend 'Qt5Agg' which requires the 'qt5' interactive framework, as 'headless' is currently running
Hello,
I have seen this issue in my end, my solution is to restart my kernel, import the following first:
import matplotlib
matplotlib.use('Qt5Agg')
Then,
import matplotlib.pyplot as plt
You probably imported matplotlib with another framework before you tried to change to Qt5Agg. Restart your kernel.
Please try and let me know. Thanks.
Regards,
Yutong
Thanks a lot for the reply.
I tried the following lines
import matplotlib
matplotlib.use('Qt5Agg')
import matplotlib.pyplot as plt
But still got the error
```
ImportError: Cannot load backend 'Qt5Agg' which requires the 'qt5' interactive framework, as 'headless' is currently running
ImportError Traceback (most recent call last)
<ipython-input-1-137a920643c4> in <module>
1 import matplotlib
2 matplotlib.use('Qt5Agg')
----> 3 import matplotlib.pyplot as plt
/anaconda/envs/myenv/lib/python3.8/site-packages/matplotlib/pyplot.py in <module>
2334 dict.setitem(rcParams, "backend", rcsetup._auto_backend_sentinel)
2335 # Set up the backend.
-> 2336 switch_backend(rcParams["backend"])
2337
2338 # Just to be safe. Interactive mode can be turned on without
/anaconda/envs/myenv/lib/python3.8/site-packages/matplotlib/pyplot.py in switch_backend(newbackend)
282 if (current_framework and required_framework
283 and current_framework != required_framework):
--> 284 raise ImportError(
285 "Cannot load backend {!r} which requires the {!r} interactive "
286 "framework, as {!r} is currently running".format(
ImportError: Cannot load backend 'Qt5Agg' which requires the 'qt5' interactive framework, as 'headless' is currently running
```
Hi, I would like to know if there is any update for this issue? I still got the error after I tried the suggested solution. And restarting the kernel did not help in my case.
10 people are following this question.