Skip to content

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

Closed as not planned

Description

@selenecodes

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

Activity

  1. timhoffm commented on Aug 7, 2023

    @timhoffm
    Member

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

  2. selenecodes commented on Aug 7, 2023

    @selenecodes
    Author

    This also happens in the commandline

  3. jklymak commented on Aug 7, 2023

    @jklymak
    Member

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

  4. tacaswell commented on Aug 7, 2023

    @tacaswell
    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.

  5. added this to the v3.7.3 milestone on Aug 7, 2023
  6. aman3002 commented on Aug 12, 2023

    @aman3002

    it works fine
    test.txt

  7. timhoffm commented on Aug 31, 2023

    @timhoffm
    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.

  8. removed this from the v3.7.3 milestone on Sep 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions