I found the error:
pip3 uninstall matplotlib
apt-get install python3-matplotlib
Solved the problem
I found the error:
pip3 uninstall matplotlib
apt-get install python3-matplotlib
Solved the problem
if 'MPLCONFIGDIR' not in os.environ or os.environ['MPLCONFIGDIR'].startswith('/home'):
import tempfile
os.environ['MPLCONFIGDIR'] = tempfile.mkdtemp()
Would you mind telling us what question type you're using as your starting point? It looks like one of our own (University of Canterbury) in-house types. Some of the ones lying around in various historic postings are very out-dated and probably should be deleted or edited to point to more recent versions. Hopefully yours isn't too old. It sounds like you've got it working, anyway.
if 'MPLCONFIGDIR' not in os.environ or os.environ['MPLCONFIGDIR'].startswith('/home'): import tempfile os.environ['MPLCONFIGDIR'] = tempfile.mkdtemp()...seems to be the most-recommended solution here, GitHub etc., but were exactly would we add this?
{{ STUDENT_ANSWER }} __student_answer__ = """{{ STUDENT_ANSWER | e('py') }}""" SEPARATOR = "##" {% for TEST in TESTCASES %} {{ TEST.testcode }} {% if not loop.last %} print(SEPARATOR) {% endif %} {% endfor %} @17943918#@>
So you can insert the extra code to set the matplotlib environment at the very beginning of that template.
A downside of this, which our much more complex question types avoid one way or another, is that the error messages the students see will all be wrong (in the students' eyes) because of the extra hidden code at the start.
A much better fix would be to modify the runguard environment in Jobe to add the appropriate environment variable when running Python if the string matplotlib is present anywhere in the source code. That way you wouldn't have to do anything to the Python source code at all. I just haven't got around to doing that yet.
import os if 'MPLCONFIGDIR' not in os.environ or os.environ['MPLCONFIGDIR'].startswith('/home'): import tempfile os.environ['MPLCONFIGDIR'] = tempfile.mkdtemp()In our OU theme, it therefore looks like this: