Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MPLCONFIGDIR error in matplotlib

When I try to import matplotlib.pyplot I get the following error:

RuntimeError("'%s' is not a writable dir; you must set %s/.matplotlib to be a writable dir.  You can also set environment variable MPLCONFIGDIR to any writable directory where you want matplotlib data stored "% (h, h))

I do have a .matplotlib directory in my home directory which is owned by me and has write permissions on. So why is it telling me it is "not a writable dir" and how do I fix this?

like image 322
2daaa Avatar asked Sep 07 '25 01:09

2daaa


1 Answers

Don't run Python as root; it not really safe, and you will potentially just run into more permissions issues later. Instead, just make sure you own the home directory and matplotlib directory:

sudo chown $USER ~ ~/.matplotlib
like image 121
simonster Avatar answered Sep 09 '25 14:09

simonster