trampgeek / jobe

jobe is a server that runs small programming jobs in a variety of programming languages
MIT License
108 stars 78 forks source link

matplotlib error due to missing environment variables #73

Open tecnologia-acceleralia opened 4 months ago

tecnologia-acceleralia commented 4 months ago

Hello,

first, I'm not sure if this is the correct place to ask for this. I'm trying to use matplotlib with CodeRunner in Moodle connecting to a Jobe server hosted in Digital Ocean. Simple scripts with python3 work well but if I try to use matplotlib I get this error:

SCRIPT:

import matplotlib.pyplot as plt
import numpy as np

# Aquí el estudiante escribe su código para generar el gráfico
x = np.arange(5)
y = np.random.randint(1, 10, size=5)
plt.bar(x, y)
plt.xlabel('Eje X')
plt.ylabel('Eje Y')
plt.title('Gráfico de barras')
plt.show()

OUTPUT:

Error in question
Bad output from grader: 
Run result: Error
Output: 
{"fraction": 1.0, "epiloguehtml": "<img src=\"data:image/png;base64,iVBORw0KGgoAAAANSU ..... \" alt=\"Gr\u00e1fico de barras\">"}

Matplotlib created a temporary config/cache directory at /tmp/matplotlib-b49jl89b because the default path (/home/jobe00/.cache/matplotlib) is not a writable directory; it is highly recommended to set the MPLCONFIGDIR environment variable to a writable directory, in particular to speed up the import of Matplotlib and to better support multiprocessing.
. Your program execution may have aborted (e.g. a timeout or memory limit exceeded).

I've tryed to configure the environment variables for "jobe" user in the jobe server but the user used to execute the job in the server does not get these values.

Username: jobe00 matplotlib uses /home/jobe00/.config/matplotlib MPLCONFIGDIR None MATPLOTLIBRC None XDG_CONFIG_HOME None MATPLOTLIBDATA None

How can I resolve that?

Thanks!

trampgeek commented 4 months ago

Please see https://github.com/trampgeek/jobeinabox/issues/13 and https://coderunner.org.nz/mod/forum/discuss.php?d=384

The issue should, I admit, be fixed in Jobe itself. There's a fix at the end of the second thread that I don't seem to have implemented in Jobe yet. Will do so now and it will appear on the next Jobe update.