Q: Python script generates all image files when run manually but not when run as a cronjob I have a Python3 script that generates png plots using matplotlib.  When I run it manually on my server, all of the plots are updated but when I run it as a cronjob, only 3 of 9 are properly updated.  I am using absolute paths for everything and the file permissions/ownerships are all identical.
What is puzzling is that the cronjob updates only some of the figures but not others whereas running manually, they're all updated.  Moreover, the three figures that are updated are created at the end of the script.
Edit: Added some sample code
This does not update my figure when run as a cronjob:
grouped = daily_data.groupby('Province_State')

grouped.apply(lambda d: plt.plot(d.date, d.Incident_Rate, label=d.Province_State.iloc[0]))
plt.savefig('incidence_rate.png')
plt.close()

But this does:
plt.plot(daily_data.loc[daily_data.Province_State=='Utah', 'date'],
         daily_data.loc[daily_data.Province_State=='Utah', 'incidence_change'],
         'C1', label="Daily")
plt.plot(daily_data.loc[daily_data.Province_State=='Utah', 'date'],
         daily_data.loc[daily_data.Province_State=='Utah', 'rolling_incidence_change_5_day'],
         'C1--', label='5 day MA')
plt.plot(daily_data.loc[daily_data.Province_State=='Utah', 'date'],
         daily_data.loc[daily_data.Province_State=='Utah', 'rolling_incidence_change_10_day'],
         'C1-.', label='10 day MA')
plt.plot(daily_data.loc[daily_data.Province_State=='Utah', 'date'],
         daily_data.loc[daily_data.Province_State=='Utah', 'rolling_incidence_change_15_day'],
         color='C1', linestyle='dotted', label='15 day MA')
plt.savefig(base_directory+'rolling_incidence_change.png')
plt.close()


A: maybe you can debug it by sending the output and the stderr to a file and comparing the manually run output file and  the cron output file
yourscript > /tmp/out.txt 2>&1


A: Ah! Having posted the code, I now see exactly what the problem is.  I haven't provided a path for the figures that fail...
