0

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?

1
  • Did i do something wrong? Its the first time I ask a question here and I would like to understand, why I did not get any answers. Commented Sep 27, 2022 at 9:09

1 Answer 1

0

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.