Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RecursionError while setting matplotlib backend #148

Open
szymonk211 opened this issue Jul 12, 2019 · 4 comments
Open

RecursionError while setting matplotlib backend #148

szymonk211 opened this issue Jul 12, 2019 · 4 comments

Comments

@szymonk211
Copy link

In Pycharm ipython console with attached debuger:

import matplotlib  
matplotlib.use("TkAgg")

causes import error:

Traceback (most recent call last):
File "/home/greensort/miniconda2/envs/borowka_fix/lib/python3.7/site-packages/IPython/core/interactiveshell.py", line 3296, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "", line 1, in
matplotlib.use("TkAgg")
File "/home/greensort/pycharm-community-2019.1.1/helpers/pydev/pydev_ipython/matplotlibtools.py", line 70, in patched_use
matplotlib.real_use(*args, **kwargs)
File "/home/greensort/pycharm-community-2019.1.1/helpers/pydev/pydev_ipython/matplotlibtools.py", line 70, in patched_use
matplotlib.real_use(*args, **kwargs)
File "/home/greensort/pycharm-community-2019.1.1/helpers/pydev/pydev_ipython/matplotlibtools.py", line 70, in patched_use
matplotlib.real_use(*args, **kwargs)
[Previous line repeated 2982 more times]
RecursionError: maximum recursion depth exceeded

@floyebolu
Copy link

floyebolu commented Oct 4, 2019

I'm also having a similar issue. The problem is in the patch_use function in pydev/pydev_ipython/matplotlibtools.py.
It appears what is happening is that matplotlib.real_use is being overwritten with patched_use on some subsequent call of matplotlib.use which leads to an infinite loop.

My intuition is that a fix would involve changing these lines:

matplotlib.real_use = matplotlib.use
matplotlib.use = patched_use

to:

try:
    real_use = matplotlib.real_use
except AttributeError:
    matplotlib.real_use = matplotlib.use
finally:
   matplotlib.use = patched_use

The try-block is to catch if the real_use attribute exists or not. If it already exists it won't be overwritten.

@davisidarta
Copy link

I'm also having this issue. Any progress on this?

@davisidarta
Copy link

Needed a full OS reinstall to solve the issue, since no other solution appeared. Everything working fine on Ubuntu 20.

@janaben
Copy link

janaben commented Mar 28, 2023

I ran into this exact problem today and the solution suggested by @floyebolu worked perfectly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants