Skip to content
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

Matplotlib crashing on Mac OS X with solution #36

Closed
krisdigital opened this issue Sep 25, 2016 · 6 comments
Closed

Matplotlib crashing on Mac OS X with solution #36

krisdigital opened this issue Sep 25, 2016 · 6 comments

Comments

@krisdigital
Copy link

I read you do not officially support OS X, but since it is mentioned in the Readme, maybe someone finds it useful or I can make a pull request.

OS X is crashing because of matplotlib, which can be avoided by setting the TkAgg backend explicitly according to http://stackoverflow.com/a/34109240/965686

import matplotlib
matplotlib.use("TkAgg")
from matplotlib import pyplot as pet

I do not know if this changes the behaviour of other systems, but I can confirm that it is working on OS X with a Homebrew Python installation.

@ValeryToda
Copy link

...Same here and same Stackoverflow source. I had to insert the following lines:

from sys import platform as sys_pf
if sys_pf == 'darwin':
    import matplotlib
    matplotlib.use("TkAgg")

at the top of the file

sms-tools/software/models_interface/models_GUI.py

to get rid of the crash.

@tardate
Copy link

tardate commented Oct 1, 2016

nice. that works. Suggest a pull request would be a great idea.

The specific error this fixed for me was:

$ python models_GUI.py
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSApplication _setup:]: unrecognized selector sent to instance 0x7fedcb3a0830'

tardate added a commit to tardate/sms-tools that referenced this issue Oct 1, 2016
tardate added a commit to tardate/sms-tools that referenced this issue Oct 1, 2016
tardate added a commit to tardate/sms-tools that referenced this issue Oct 12, 2016
(redone without whitespace fixups)
@DavidAntliff
Copy link

For completeness, you can also create this file, to avoid a code change (which may or may not be preferable):

$ mkdir -p ~/.matplotlib
$ echo "backend: TkAgg" > ~/.matplotlib/matplotlibrc

@xserra
Copy link
Member

xserra commented May 8, 2017

Solved, so closing.

@mjspeck
Copy link

mjspeck commented Nov 28, 2018

Why is the solution to this to use TkAgg instead of macosx for the backend?

@janosh
Copy link

janosh commented Jan 27, 2019

@xserra I don't think this is solved. I'm still running into this issue with matplotlib v3.0.2 installed into a miniconda environment on macOS:

conda list matplotlib
# packages in environment at /usr/local/miniconda3/envs/te:
#
# Name                    Version                   Build  Channel
matplotlib                3.0.2                 py36_1001    conda-forge
matplotlib-base           3.0.2           py36hf043ca5_1001    conda-forge

Attempting

from matplotlib import pyplot as plt
plt.plot(range(10))

throws the following exception

python[35172:6260598] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSApplication _setup:]: unrecognized selector sent to instance 0x7fccc5e0a500'
*** First throw call stack:
(
        0   CoreFoundation                      0x00007fff2f3c9ecd __exceptionPreprocess + 256
        1   libobjc.A.dylib                     0x00007fff5b481720 objc_exception_throw + 48
        2   CoreFoundation                      0x00007fff2f447275 -[NSObject(NSObject) __retain_OA] + 0
        3   CoreFoundation                      0x00007fff2f36bb40 ___forwarding___ + 1486
        4   CoreFoundation                      0x00007fff2f36b4e8 _CF_forwarding_prep_0 + 120
        5   libtk8.6.dylib                      0x0000000121d0b134 TkpInit + 324
        6   libtk8.6.dylib                      0x0000000121c630ce Initialize + 2622
        7   _tkinter.cpython-36m-darwin.so      0x0000000121a8ca46 _tkinter_create + 1174
        ...

If I instead run the following, everything works fine.

import matplotlib
matplotlib.use("TkAgg")
from matplotlib import pyplot as plt
plt.plot(range(10))
plt.show()

JohSchoeneberg added a commit to readdy/custom-integrator-example that referenced this issue Feb 15, 2019
Running matplot lib on MacOS yielded to a crash on my system in matplotlib. This patch fixes that problem. See here: MTG/sms-tools#36
sebastian-luna-valero added a commit to cgat-developers/cgat-apps that referenced this issue Mar 7, 2019
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

7 participants