You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: lib/matplotlib/__init__.py
+18-6Lines changed: 18 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -323,16 +323,28 @@ def _get_home():
323
323
324
324
def_get_configdir():
325
325
"""
326
-
Return the string representing the configuration dir. If s is the
327
-
special string _default_, use HOME/.matplotlib. s must be writable
326
+
Return the string representing the configuration dir.
327
+
328
+
default is HOME/.matplotlib. you can override this with the
329
+
MPLCONFIGDIR environment variable
328
330
"""
329
-
h=get_home()
330
-
ifnot_is_writable_dir(h):
331
-
raiseRuntimeError("'%s' is not a writable dir; you must set environment variable HOME to be a writable dir "%h)
332
331
332
+
configdir=os.environ.get('MPLCONFIGDIR')
333
+
ifconfigdirisnotNone:
334
+
ifnot_is_writable_dir(configdir):
335
+
raiseRuntimeError('Could not write to MPLCONFIGDIR="%s"'%configdir)
336
+
returnconfigdir
337
+
338
+
h=get_home()
333
339
p=os.path.join(get_home(), '.matplotlib')
340
+
341
+
ifos.path.exists(p):
342
+
ifnot_is_writable_dir(p):
343
+
raiseRuntimeError("'%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)
344
+
else:
345
+
ifnot_is_writable_dir(h):
346
+
raiseRuntimeError("Failed to create %s/.matplotlib; consider setting MPLCONFIGDIR to a writable directory for matplotlib configuration data"%h)
0 commit comments