Skip to content
This repository has been archived by the owner on Aug 29, 2023. It is now read-only.

cate on MacOS - failure to create plots (with solution) #849

Open
cipogh opened this issue Jul 3, 2019 · 1 comment
Open

cate on MacOS - failure to create plots (with solution) #849

cipogh opened this issue Jul 3, 2019 · 1 comment

Comments

@cipogh
Copy link

cipogh commented Jul 3, 2019

Expected behavior

cate should display plots maps and time series (in Desktop mode) or create a plot file (in Command Line mode)
Taking as example the workflow in https://cate.readthedocs.io/en/latest/quick_start.html, the various figures in the example should be created as png files - or displayed on screen if running the equivalent set of operations in Desktop mode

Actual behaviour

the desktop version stalls (without throwing any error) when attempting to create a plot. The Command Line interface throws an error message with multiple exception codes, see example below.

Steps to reproduce the problem

Using a subset of the example in https://cate.readthedocs.io/en/latest/quick_start.html:

  1. $ cate ws new
  2. $ cate res open oz07 esacci.OZONE.mon.L3.NP.multi-sensor.multi-platform.MERGED.fv0002.r1 2007-01-01 2007-12-30
  3. $ cate res set oz_tot select_var ds=@oz07 var=O3_du_tot
  4. $ cate ws run plot_map ds=@oz_tot var=O3_du_tot file=fig2.png

At this point the CLI trows the error:

Running operation 'plot_map': started 2019-07-03 11:03:32.124 python[5898:430814] -[NSApplication _setup:]: unrecognized selector sent to instance 0x7ff2f0cd9d90
2019-07-03 11:03:32.169 python[5898:430814] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSApplication _setup:]: unrecognized selector sent to instance 0x7ff2f0cd9d90'
*** First throw call stack:
(
0 CoreFoundation 0x00007fff4ddb865b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x00007fff75040c76 objc_exception_throw + 48
2 CoreFoundation 0x00007fff4de511b4 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132
3 CoreFoundation 0x00007fff4dd2df70 forwarding + 1456
4 CoreFoundation 0x00007fff4dd2d938 _CF_forwarding_prep_0 + 120
5 libtk8.6.dylib 0x000000031642931d TkpInit + 413
6 libtk8.6.dylib 0x000000031638117e Initialize + 2622
7 _tkinter.cpython-37m-darwin.so 0x00000003137bca0f _tkinter_create + 1183
.....

Specifications

cate v2.0.0. on MacOs High Sierra 10.13.6

Interpretation and solution

The problem appears to be that the matplotlib plotting library on the OSX installation does not see the TkAgg backend to actually render the plots.
This matplotlib issue on MacOS has been reported elsewhere on GitHub:
MTG/sms-tools#36
One way of fixing this issue is as shown in MTG/sms-tools#36 (comment) i.e. by prescribing TkAgg in matplotlibrc, for instance like that:
$ mkdir -p ~/.matplotlib
$ echo "backend: TkAgg" > ~/.matplotlib/matplotlibrc

After this both the Desktop and the CLI appear to output plots correctly

@forman
Copy link
Member

forman commented Sep 30, 2019

@cipogh thanks for investigating.

I have not seen this problem so far. Cate does not set a default matplotlib backend and from official matplotlib docs:

With a typical installation of matplotlib, such as from a binary installer or a linux distribution package, a good default backend will already be set, allowing both interactive work and plotting from scripts, with output to the screen and/or to a file, so at least initially you will not need to use any of the methods given above.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants