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 macosx verify later#12557

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

Closed

Conversation

jklymak
Copy link
Member

@jklymakjklymak commentedOct 18, 2018
edited
Loading

PR Summary

This moves the verification of the framework build out ofimport _macosx, allowing us to
call that more often, and into the creation of the figure manager...

Closes#12188

Update (19 Oct 2018)

Moved MacOSx framework check topyplot.py so it errors at the same place as before rather than waiting for a draw.

Note this doesn't fix the bouncing icon in the framework build if one indeed wants to use themacosx backend, but it doesn't pop one up everytime regardless of the backend.

Not sure what changed in 3.0 to cause the icon to start bouncing, but this should cure the problem for 75% of the users who just want to use Matplotlib with a different backend, like a notebook...

Icon bouncing is because we initialize the window manager connection to python, but we don't open a window, so the app is in an in-between state of readiness.

Until conda ships a python that we can test if its a FRAMEWORK app, I am not sure we will fix this any better than this. Note the vast improvement here is that the bouncing doesn't happen forevery backend like it does in 3.0.0

Non-framework python

this PR

>>> import matplotlib; matplotlib.use('macosx'); import matplotlib.pyplot

yields: No icon popped up and

Traceback (most recent call last):  File "testbackend.py", line 3, in <module>    import matplotlib.pyplot  File "/Users/jklymak/matplotlib/lib/matplotlib/pyplot.py", line 2357, in <module>    "Python is not installed as a framework. The Mac OS X backend "ImportError: Python is not installed as a framework. The Mac OS X backend will not be able to function correctly if Python is not  installed as a framework. See the Python documentation for more  information on installing Python as a framework on Mac OS X. Please either reinstall Python as a framework, or try one of the other backends. If you are using (Ana)Conda please install python.app and replace the use of 'python' with 'pythonw'. See 'Working with Matplotlib on OSX' in the Matplotlib FAQ for more information.

V 2.2.3

As above, though the stacktrace is deeper:

 File "<stdin>", line 1, in <module>  File "/Users/jklymak/matplotlib/lib/matplotlib/pyplot.py", line 115, in <module>    _backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()  File "/Users/jklymak/matplotlib/lib/matplotlib/backends/__init__.py", line 62, in pylab_setup    [backend_name], 0)  File "/Users/jklymak/matplotlib/lib/matplotlib/backends/backend_macosx.py", line 17, in <module>

V3.0.0

Error is on import as above.

Framework python

V3.0.0

>>>  import matplotlib; matplotlib.use('macosx'); import matplotlib.pyplot as pyplot

Icon pops up, bounces, and terminal loses focus.

>>>  import matplotlib; matplotlib.use('qt5agg'); import matplotlib.pyplot as pyplot

Icon pops up, bounces, and terminal loses focus.

this PR

>>>  import matplotlib; matplotlib.use('macosx'); import matplotlib.pyplot as pyplot

Icon bounces until a draw is calledand terminal loses focus but focus returns to terminal.

>>>  import matplotlib; matplotlib.use('qt5agg'); import matplotlib.pyplot as pyplot

No icon pops up....

V2.2.3

>>>  import matplotlib; matplotlib.use('macosx'); import matplotlib.pyplot as pyplot

Icon pops up, but doesn't bounce.

PR Checklist

  • Has Pytest style unit tests
  • Code isFlake 8 compliant
  • New features are documented, with examples if plot related
  • Documentation is sphinx and numpydoc compliant
  • Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there)
  • Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way

@jklymakjklymak added the Release criticalFor bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions. labelOct 18, 2018
@jklymakjklymak added this to thev3.0.x milestoneOct 18, 2018
@jklymak
Copy link
MemberAuthor

Note that moving the check later is kind of an API change.

@jklymakjklymak requested a review fromanntzerOctober 18, 2018 19:45
@jklymak
Copy link
MemberAuthor

So, previously, the check triggered onimport matplotlib.pyplot as plt now it doesn't trigger untilplt.plot()

import matplotlib; matplotlib.use('macosx'); import matplotlib.pyplot as plt; plt.plot(range(10))

@anntzer
Copy link
Contributor

AFAICT this "won't work" for reasons explained in#12188 (comment). Not that I have a better solution though.

@anntzeranntzer removed their request for reviewOctober 18, 2018 20:40
@jklymak
Copy link
MemberAuthor

jklymak commentedOct 18, 2018
edited
Loading

Thanks for the detailed comment in
#12188 (comment)

I'll still argue that the proposed change here is "better", even if it doesn't give mac users the fallback as desired.

Right now if we use the non-framework build on a Mac, and no backend is specified, and wedon't call matplotlib.use, macosx will try to run with the macosx backend, and will fail when the figure manager is instantiated becauseverify_framework will returnFalse. Then the user then knows that they should change to the framework build, or manually set their backend.

Yes, it'd be slicker to fallback to Qt5 etc, but I think this proposed behaviour is better than popping up the_macosx GUI every time we import pyplot, even if the user is using a Jupyter Notebook, or has manually set in the matplotlibrc to Qt5Agg, etc.

[Slightly tangential: I'd still actually argue we shouldn't outright fail using the non-framework Mac build. Yes some interactivity is broken, but you can still make plots. I'd change the Error to a Warning.]

@anntzer
Copy link
Contributor

The argument seems reasonable, and I honestly can't pretend I care enough about OSX subtleties to have a strong opinion against (or for) the changes here, as long as you understand the pros and cons I explained.

@jklymak
Copy link
MemberAuthor

... well I don't care about the subtleties of OSX pythons either, but I guess we can't break Matplotlib for our Mac users given that a pretty big fraction of the scientific community uses Macs. This isn't just conda - it affects the system Framework build and the macports build as well.

@anntzer
Copy link
Contributor

I'm not saying that the fix is not important, just that I can't really judge the tradeoffs involved in either approach.

@tacaswell
Copy link
Member

@jklymak this needs a rebase....

@jklymak
Copy link
MemberAuthor

Obsoleted by#12603

@QuLogicQuLogic modified the milestones:v3.0.x,unassignedOct 24, 2018
@jklymakjklymak deleted the fix-macosx-verify-later branchOctober 24, 2018 02:35
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
GUI: MacOSXOS: AppleRelease criticalFor bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

matplotlib 3 pyplot on MacOS bounces rocket icon in dock
4 participants
@jklymak@anntzer@tacaswell@QuLogic

[8]ページ先頭

©2009-2025 Movatter.jp