Skip to content
← Back to Community
How do i go about setting 'the MPLCONFIGDIR environment variable to a writable directory?'
Profile icon
JazzKeyboards

Matplotlib created a temporary config/cache directory at /tmp/matplotlib-wvc1s_4i because the default path (/config/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.

Thank you in advance

Voters
Profile icon
seanrattigan
Profile icon
Zainsk
Profile icon
SewoongJun
Profile icon
eric_wang
Profile icon
DevsSaturdaysAI
Profile icon
JazzKeyboards
Comments
hotnewtop
Profile icon
MkpReplit

If you stumble upon this, my solution is to add those folling lines of code before importing matplotlib:

import os
import tempfile
os.environ["MPLCONFIGDIR"] = tempfile.gettempdir()

Profile icon
Coder100

read this

Conclusion

It is only a warning, you can safely ignore it unless you really need those 2 ms of speed.

Profile icon
JazzKeyboards

@Coder100 OK. So if I understand you correctly, this warning should have no impact on program execution. Is that correct?

Profile icon
Coder100
Profile icon
JazzKeyboards

@Coder100 thank you

Profile icon
MkpReplit

If you stumble upon this, my solution is to add those following lines of code before importing matplotlib:

import os
import tempfile
os.environ["MPLCONFIGDIR"] = tempfile.gettempdir()

Profile icon
MkpReplit

If you stumble upon this, my solution is to add those folling lines of code before importing matplotlib:

import os
import tempfile
os.environ["MPLCONFIGDIR"] = tempfile.gettempdir()

Profile icon
hoffm386

Given how slow all of the library imports are, I'm interested in trying to improve this even if it's "unnecessary"

Does anyone have any hints about the file system setup being used by repl.it, to figure out how to configure this?

Profile icon
techde

you cna go to that cache and check what your code should look like btw.

Profile icon
techde

Your not writing it to a dir