Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix IPython import issue#19597

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
QuLogic merged 2 commits intomatplotlib:masterfromBolton-and-Menk-GIS:ipython_fix
Mar 1, 2021

Conversation

philnagel
Copy link
Contributor

When blocking import ofIPython by definingsys.modules["IPython"] = None, creating plots fails becausebackend_bases.FigureCanvasBase._fix_ipython_backend2gui attempts to check ifIPython is already imported by looking for an entry insys.modules. It then attempts to importIPython, which fails due to the import being blocked.

Code sample to reproduce the issue:

import syssys.modules['IPython'] = Nonefrom matplotlib import pyplotplt = pyplot.subplots(1,1)

which results in:

Traceback (most recent call last):  File "<module1>", line 5, in <module>  File "C:\Users\Phil\envs\mp_dev\lib\site-packages\matplotlib\cbook\deprecation.py", line 451, in wrapper    return func(*args, **kwargs)  File "C:\Users\Phil\envs\mp_dev\lib\site-packages\matplotlib\pyplot.py", line 1287, in subplots    fig = figure(**fig_kw)  File "C:\Users\Phil\envs\mp_dev\lib\site-packages\matplotlib\pyplot.py", line 687, in figure    figManager = new_figure_manager(num, figsize=figsize,  File "C:\Users\Phil\envs\mp_dev\lib\site-packages\matplotlib\pyplot.py", line 315, in new_figure_manager    return _backend_mod.new_figure_manager(*args, **kwargs)  File "C:\Users\Phil\envs\mp_dev\lib\site-packages\matplotlib\backend_bases.py", line 3493, in new_figure_manager    fig = fig_cls(*args, **kwargs)  File "C:\Users\Phil\envs\mp_dev\lib\site-packages\matplotlib\figure.py", line 341, in __init__    FigureCanvasBase(self)  # Set self.canvas.  File "C:\Users\Phil\envs\mp_dev\lib\site-packages\matplotlib\backend_bases.py", line 1686, in __init__    self._fix_ipython_backend2gui()  File "C:\Users\Phil\envs\mp_dev\lib\site-packages\matplotlib\backend_bases.py", line 1713, in _fix_ipython_backend2gui    import IPythonModuleNotFoundError: import of IPython halted; None in sys.modules

This PR addresses this issue by not only checking ifIPython is present insys.modules, but also if it is blocked from being imported.

Copy link

@github-actionsgithub-actionsbot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Thank you for opening your first PR into Matplotlib!

If you have not heard from us in a while, please feel free to ping@matplotlib/developers or anyone who has commented on the PR. Most of our reviewers are volunteers and sometimes things fall through the cracks.

You can also join uson gitter for real-time discussion.

For details on testing, writing docs, and our review process, please seethe developer guide

We strive to be a welcoming and open project. Please follow ourCode of Conduct.

@tacaswell
Copy link
Member

Well, I just learned something about the expected behavior ofsys.modules (could not quickly find documentation of this, but found a bug report where CPython made sure this behavior worked as expectedhttps://bugs.python.org/issue31642 which is good enough for me).

@tacaswelltacaswell added this to thev3.4.0 milestoneFeb 28, 2021
@tacaswell
Copy link
Member

This suggests we should make a similar change inqt_compat.py where we try to sort out if any of the Qt frameworks are imported already.

@anntzeranntzer mentioned this pull requestFeb 28, 2021
7 tasks
@QuLogicQuLogic merged commitb0aab9f intomatplotlib:masterMar 1, 2021
meeseeksmachine pushed a commit to meeseeksmachine/matplotlib that referenced this pull requestMar 1, 2021
@QuLogic
Copy link
Member

Thanks@philnagel! Congratulations on your first PR to Matplotlib 🎉 We hope to hear from you again.

QuLogic added a commit that referenced this pull requestMar 2, 2021
…597-on-v3.4.xBackport PR#19597 on branch v3.4.x (Fix IPython import issue)
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@anntzeranntzeranntzer left review comments

@github-actionsgithub-actions[bot]github-actions[bot] left review comments

@tacaswelltacaswelltacaswell approved these changes

@QuLogicQuLogicQuLogic approved these changes

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
v3.4.0
Development

Successfully merging this pull request may close these issues.

4 participants
@philnagel@tacaswell@QuLogic@anntzer

[8]ページ先頭

©2009-2025 Movatter.jp