How to resolve Gdk-CRITICAL **: 17:13:03.280: gdk_cursor_new_for_display: assertion 'GDK_IS_DISPLAY (display)' failed

Viewed 6514

After an upgrade to ubuntu 20.04 i receive this error from a python script launched from crontab:

Unable to init server: Could not connect: Connection refused
Unable to init server: Could not connect: Connection refused

(generate_clocks_graphs.py:4888): Gdk-CRITICAL **: 17:13:03.280: gdk_cursor_new_for_display: assertion 'GDK_IS_DISPLAY (display)' failed

Is there a way to understand better this error? I cannot find a solution The oddity is that if i run manually the script, it works perfectly

1 Answers

looking at the code I realized that I had not put the following lines of code:

import matplotlib
matplotlib.use('Agg')

after entering them, the script also works running crontab

thank you

Related