Issue
I am using a Python3 installation in a Ubuntu distribution in WSL2 on a Windows 10 machine.
Over the last two months, i did not code that much. Now i started again and faced the following issue:
The following code hangs for ~2min:
import matplotlib.pyplot
After 2 min, i got the following output:
Traceback (most recent call last):
File "a.py", line 5, in <module>
import matplotlib.pyplot as plt
File "/home/markus/.local/lib/python3.8/site-packages/matplotlib/pyplot.py", line 2469, in <module>
switch_backend(rcParams["backend"])
File "/home/markus/.local/lib/python3.8/site-packages/matplotlib/pyplot.py", line 277, in switch_backend
class backend_mod(matplotlib.backend_bases._Backend):
File "/home/markus/.local/lib/python3.8/site-packages/matplotlib/pyplot.py", line 278, in backend_mod
locals().update(vars(importlib.import_module(backend_name)))
File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "/home/markus/.local/lib/python3.8/site-packages/matplotlib/backends/backend_qt4agg.py", line 6, in <module>
from .backend_qt5agg import (
File "/home/markus/.local/lib/python3.8/site-packages/matplotlib/backends/backend_qt5agg.py", line 11, in <module>
from .backend_qt5 import (
File "/home/markus/.local/lib/python3.8/site-packages/matplotlib/backends/backend_qt5.py", line 13, in <module>
import matplotlib.backends.qt_editor.figureoptions as figureoptions
File "/home/markus/.local/lib/python3.8/site-packages/matplotlib/backends/qt_editor/figureoptions.py", line 11, in <module>
from matplotlib.backends.qt_compat import QtGui
File "/home/markus/.local/lib/python3.8/site-packages/matplotlib/backends/qt_compat.py", line 179, in <module>
raise ImportError("Failed to import any qt binding")
ImportError: Failed to import any qt binding
The issue has already been described here: import matplotlib.pyplot hangs
But the suggested solutions did not work.
I then ran
sudo pip install --upgrade matplotlib
which helped, as the import command works now, but it still takes 2 min to execute!
Do you know, why this command takes so much time?
Solution
Uninstalling and reinstalling Matlplotlib did not help.
Uninstalling and reinstalling python 3.X did not help.
What did work was resetting the Ubuntu installation in the windows settings, e.g. see here:
https://askubuntu.com/questions/761360/how-do-i-reset-my-installation-of-ubuntu-on-windows
Answered By - Markus
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.