Skip to content

PyPlot Crashing Mac OS 10.14.6 #454

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
ghost opened this issue Aug 9, 2019 · 17 comments
Closed

PyPlot Crashing Mac OS 10.14.6 #454

ghost opened this issue Aug 9, 2019 · 17 comments

Comments

@ghost
Copy link

ghost commented Aug 9, 2019

I am using Mac OS 10.14.6 and Julia 1.1.1.

I just executed a script in the Julia terminal, imported PyPlot, and got logged out of my computer upon executing plot. After logging back in, I was able to recover my Julia session which said:

2019-08-09 14:30:47.868 julia[5602:179629] HIToolbox: received notification of WindowServer event port death.
2019-08-09 14:30:47.868 julia[5602:179629] port matched the WindowServer port created in BindCGSToRunLoop

I'll restart my computer to see if this persists, but something in the pipeline seems to have gone adrift!

@ghost
Copy link
Author

ghost commented Aug 9, 2019

Even after restarting my computer I get the similar error message:

2019-08-09 14:49:53.190 julia[560:8205] CGSTrackingRegionSetIsEnabled returned CG error 268435459
2019-08-09 14:49:53.190 julia[560:8205] CGSTrackingRegionSetIsEnabled returned CG error 268435459
2019-08-09 14:49:53.190 julia[560:8205] CGSTrackingRegionSetIsEnabled returned CG error 268435459
2019-08-09 14:49:53.190 julia[560:8205] CGSTrackingRegionSetIsEnabled returned CG error 268435459
2019-08-09 14:49:53.190 julia[560:8205] CGSTrackingRegionSetIsEnabled returned CG error 268435459
2019-08-09 14:49:53.190 julia[560:8205] CGSTrackingRegionSetIsEnabled returned CG error 268435459
2019-08-09 14:49:53.190 julia[560:8205] CGSTrackingRegionSetIsEnabled returned CG error 268435459
2019-08-09 14:49:53.190 julia[560:8205] CGSTrackingRegionSetIsEnabled returned CG error 268435459
2019-08-09 14:49:53.190 julia[560:8205] CGSTrackingRegionSetIsEnabled returned CG error 268435459
2019-08-09 14:49:53.190 julia[560:8205] CGSTrackingRegionSetIsEnabled returned CG error 268435459
2019-08-09 14:49:53.190 julia[560:8205] CGSTrackingRegionSetIsEnabled returned CG error 268435459
2019-08-09 14:49:53.190 julia[560:8205] CGSTrackingRegionSetIsEnabled returned CG error 268435459
2019-08-09 14:49:53.190 julia[560:8205] CGSTrackingRegionSetIsEnabled returned CG error 268435459
2019-08-09 14:49:53.190 julia[560:8205] CGSTrackingRegionSetIsEnabled returned CG error 268435459
2019-08-09 14:49:53.190 julia[560:8205] CGSTrackingRegionSetIsEnabled returned CG error 268435459
2019-08-09 14:49:53.190 julia[560:8205] CGSTrackingRegionSetIsEnabled returned CG error 268435459
2019-08-09 14:50:03.214 julia[560:8205] HIToolbox: received notification of WindowServer event port death.
2019-08-09 14:50:03.214 julia[560:8205] port matched the WindowServer port created in BindCGSToRunLoop
1-element Array{PyCall.PyObject,1}:
PyObject <matplotlib.lines.Line2D object at 0x130d8be10>

@ghost
Copy link
Author

ghost commented Aug 9, 2019

Even after restarting and removing and adding PyPlot, the problem persists.

@ghost ghost changed the title WindowServer event port death PyPlot Crashing Mac OS 10.14.6 Aug 9, 2019
@thuwzr
Copy link

thuwzr commented Aug 17, 2019

The same problem for me.

@sunqingmeteo
Copy link

Similar error for me. When I use matplotlib excute "plt.show()". Mac went back to lock screen and need password. Seem like restart system.

Error Info:
python[70866:7884671] HIToolbox: received notification of WindowServer event port death.

@sunqingmeteo
Copy link

I think the problem was caused by conda to set python environment and did not have figure show windows like X11.

@dgleich
Copy link

dgleich commented Aug 22, 2019

Seems this happened with the recent update.
https://discussions.apple.com/thread/250550587?answerId=251098439022#251098439022

Also, I ran
using Conda; Conda.update()

to update all the PyPlot Conda stuff it installs behind the hood. This stopped the crashing, but it doesn't exactly work with the GUI... (but I think the PlotPane works in Atom...)

I don't get figure windows after doing

@stevengj
Copy link
Member

stevengj commented Sep 3, 2019

What is PyPlot.backend?

@dgleich
Copy link

dgleich commented Sep 3, 2019

julia> PyPlot.backend
"TkAgg"

@stevengj
Copy link
Member

stevengj commented Sep 3, 2019

The TkAgg backend has been broken on MacOS for a while (#410), due to an upstream bug in the Python tkinter library. (It crashes if you use it from Python as well.)

However, the current version of PyPlot does not use tkagg by default anymore on MacOS for this reason. The only way it could be using tkagg is if you "forced" it to by specifying it in either your .matplotlibrc file or via the MPLBACKEND environment variable.

You can find the location of your matplotlibrc file by doing:

using PyCall
pyimport("matplotlib").matplotlib_fname()

See if it has a line like backend: TkAgg

@dgleich
Copy link

dgleich commented Sep 3, 2019

Hmm... nothing with backend seems to be listed Curious!

julia> pyimport("matplotlib").matplotlib_fname()
"/Users/dgleich/.julia/conda/3/lib/python3.7/site-packages/matplotlib/mpl-data/matplotlibrc"
shell> grep backend /Users/dgleich/.julia/conda/3/lib/python3.7/site-packages/matplotlib/mpl-data/matplotlibrc
## The default backend. If you omit this parameter, the first
## working backend from the following list is used:
## You can also deploy your own backend outside of matplotlib by
## 'module://my_backend'.
#backend      : Agg
## The port to use for the web server in the WebAgg backend.
## if you are running pyplot inside a GUI and your backend choice
## you if backend_fallback is True
#backend_fallback: True
                         ## This only affects the Agg backend.
                                ## backends but will workd with temporary file based ones:
### tk backend params
### ps backend params
### pdf backend params
### svg backend params
#animation.writer : ffmpeg         ## MovieWriter 'backend' to use

@stevengj
Copy link
Member

stevengj commented Sep 3, 2019

The other reason it would try tkagg is if all of the other backends fail.

Does

using PyCall
pyimport_conda("PyQt5", "pyqt")

work?

@dgleich
Copy link

dgleich commented Sep 3, 2019

Great! That installed nicely and that does work!

Results:

julia> pyimport_conda("PyQt5", "pyqt")
[ Info: Installing PyQt5 via the Conda pyqt package...
[ Info: Running `conda install -y pyqt` in root environment
Collecting package metadata (current_repodata.json): done
Solving environment: done

restart julia (probably not necessary, but I was being careful...)

julia> using PyPlot

julia> PyPlot.backend
"Qt5Agg"

@stevengj
Copy link
Member

stevengj commented Sep 3, 2019

@dgleich, that's great, but I'm still confused — the function pyimport_conda("PyQt5", "pyqt") should be called automatically when PyPlot is initialized since the qt5 backend is the default first choice it tries on macos.

@dgleich
Copy link

dgleich commented Sep 3, 2019

I had a feeling you'd be as confused as I was about that .. I spent a few minutes trying to debug at the computer having the problem last night, but didn't quite get there. I'll take another look tonight and see what I can dig out.

My quick guess is that default is coming back 'none' ?

@stevengj
Copy link
Member

stevengj commented Sep 3, 2019

Oh, right, it only installs qt5 automatically if that GUI was explicitly requested, not if it goes through the search list.

I should change that, maybe at least add an optional prompt to install it.

@stevengj
Copy link
Member

stevengj commented Sep 4, 2019

Okay, I've pushed a patch which forces it to install pyqt on MacOS if nothing else was installed and you are using Conda, and it at least prints a warning if you try to make it use TkAgg on MacOS.

@dgleich
Copy link

dgleich commented Sep 4, 2019

Fantastic! I think that's the right call. Also, got to check that computer right now...

In this case, the default backend that comes from Matplotlib is:

julia> matplotlib = pyimport_conda("matplotlib","matplotlib")
julia> rcParams = PyDict(matplotlib."rcParams")
julia> default = lowercase(get(ENV, "MPLBACKEND",
                            getnone(rcParams, "backend", "none")))
julia> default
"macosx"

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