Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Bug]: 'NoneType' object has no attribute 'pyplot_show' #26463

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

Closed
selenecodes opened this issue Aug 7, 2023 · 6 comments
Closed

[Bug]: 'NoneType' object has no attribute 'pyplot_show' #26463

selenecodes opened this issue Aug 7, 2023 · 6 comments

Comments

@selenecodes
Copy link

Bug summary

When trying to run plt.show the graph isn't being shown and instead the following error is raised:
'NoneType' object has no attribute 'pyplot_show'

Code for reproduction

import matplotlib.pyplot as plt
import numpy as np
# from tests import generate_fake_data
x = [i for i in range(10)]# generate_fake_data.generate_time_data()
y = [i for i in range(10)] # list(np.random.rand(10))
fig, ax = plt.subplots()
ax.plot(x, y, linewidth=2.0)
plt.show()

Actual outcome

Matplotlib support failed
Traceback (most recent call last):
File "C:\Program Files\JetBrains\PyCharm Community Edition 2021.1.3\plugins\python-ce\helpers\pydev_pydev_bundle\pydev_import_hook.py", line 25, in do_import
succeeded = activate_func()
File "C:\Program Files\JetBrains\PyCharm Community Edition 2021.1.3\plugins\python-ce\helpers\pydev_pydev_bundle\pydev_code_executor.py", line 27, in
"matplotlib": lambda: activate_matplotlib(self.enableGui),
File "C:\Program Files\JetBrains\PyCharm Community Edition 2021.1.3\plugins\python-ce\helpers\pydev\pydev_ipython\matplotlibtools.py", line 110, in activate_matplotlib
gui, backend = find_gui_and_backend()
File "C:\Program Files\JetBrains\PyCharm Community Edition 2021.1.3\plugins\python-ce\helpers\pydev\pydev_ipython\matplotlibtools.py", line 47, in find_gui_and_backend
backend = matplotlib.rcParams['backend']
File "C:\Users\jopva\Projects\rws-dataviz\venv\lib\site-packages\matplotlib_init_.py", line 777, in getitem
plt.switch_backend(rcsetup._auto_backend_sentinel)
File "C:\Users\jopva\Projects\rws-dataviz\venv\lib\site-packages\matplotlib\pyplot.py", line 256, in switch_backend
switch_backend(candidate)
File "C:\Users\jopva\Projects\rws-dataviz\venv\lib\site-packages\matplotlib\pyplot.py", line 337, in switch_backend
backend_mod.show = manager_class.pyplot_show
AttributeError: 'NoneType' object has no attribute 'pyplot_show'

Expected outcome

Show a chart

Additional information

It worked fine on 3.7.0
Downgrading to version 3.7.0 fixes it.

Operating system

Windows 11

Matplotlib Version

3.7.2

Matplotlib Backend

TkAgg

Python version

3.9.6

Jupyter version

No response

Installation

None

@timhoffm
Copy link
Member

timhoffm commented Aug 7, 2023

Seems you are running from within Pycharm. Does this also happen from the commandline or ipython?

@selenecodes
Copy link
Author

This also happens in the commandline

@jklymak
Copy link
Member

jklymak commented Aug 7, 2023

Please include the Traceback from the command line error because the Traceback you have given appears to have the problem emanating from pycharm.

@tacaswell
Copy link
Member

Looking at blame it suggests that #25246 is the offending commit which suggests that this also exists on main and was put in specifically to unbreak pycharm 🤦🏻

Do we have any active contacts at jetbrains? I had some back-channel communication from 2017 that I tried to follow up on so we will see how that goes.

@tacaswell tacaswell added this to the v3.7.3 milestone Aug 7, 2023
@aman3002
Copy link

it works fine
test.txt

@timhoffm
Copy link
Member

This works for me on recent versions of PyCharm (tested with 2022.2.5 and 2023.2.1). It looks like you are still using 2021.1.3. Please update PyCharm and check whether the error persists.

@QuLogic QuLogic removed this from the v3.7.3 milestone Sep 6, 2023
@timhoffm timhoffm closed this as not planned Won't fix, can't repro, duplicate, stale Mar 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants