Even though this is an internal cache, we should document that we are moving it on windows (as I'm sure there exist other users who have discovered where it lives and are either deleting it (for reasons) or pre-populating it (again, for reasons).
Milestoned for 3.6, but if it is ready it can go in for 3.5. Labeled good first issue because it only requires changing details of how we discover the cache directory and should not touch our public API (other than a sideeffect of where files go), but may require intermediate Python (as I think we want to generalize _get_xgd_cache_dir to also have a windows path) and familiarity with Windows.
# Only call _xdg_base_getter here so that MPLCONFIGDIR is tried first,
# as _xdg_base_getter can throw.
configdir=Path(xdg_base_getter(), "matplotlib")
else:
configdir=Path.home() /".matplotlib"
On Windows, I think we need to differentiate between %APPDATA% for roaming config data (get_configdir) and %LOCALAPPDATA% for local cache data (get_cachedir).
@tacaswell If we want to fix this particular issue #20779 for Windows, I can make a PR.
(Switching to appdirs #12549 is beyond me as I have no masOS or FreeBSD to test it and update the documention of get_configdir and get_cachedir. I couldn't find docs for appdirs (apart from the README file) that we could refer to for the details about folder selection on different OSs.)
@StefRe Yes, I understand, but if you're going to fix this, I really think using appdirs is the right approach. They have already tested to make sure that their folder choices are correct. Otherwise, you'll just be fixing it for one OS for now, and it could easily break again one day. More importantly, the folders are messed up on all operating systems for the rest of us.
I also don't think it's that much harder to use appdirs than to do this manually. Just call appdirs.user_data_dir(appname='matplotlib', appauthor='matplotlib', version=..., roaming=False) and use that path.
Hi, I'd like to work on this issue. I'll implement the change to use \platformdirs\ (the maintained replacement for \�ppdirs) to properly place the matplotlib configuration and cache directories on Windows (%LOCALAPPDATA% for cache, %APPDATA% for config if roaming is desired, otherwise %LOCALAPPDATA%).
@timhoffm Could you please reopen the issue? This is only fixed on Windows, and in a very brittle way. Or perhaps we should open a separate issue for relying on platformdirs?
Activity
tacaswell commented on Aug 2, 2021
Do you have a reference for what "should" be in various places?
I suspect that this would be addressed by #12549 , but if we do not want to pick up that dependency, the place in the code to make the change is
matplotlib/lib/matplotlib/__init__.py
Lines 470 to 478 in e291cdb
Even though this is an internal cache, we should document that we are moving it on windows (as I'm sure there exist other users who have discovered where it lives and are either deleting it (for reasons) or pre-populating it (again, for reasons).
tacaswell commented on Aug 2, 2021
Milestoned for 3.6, but if it is ready it can go in for 3.5. Labeled good first issue because it only requires changing details of how we discover the cache directory and should not touch our public API (other than a sideeffect of where files go), but may require intermediate Python (as I think we want to generalize _get_xgd_cache_dir to also have a windows path) and familiarity with Windows.
Erithax commented on Aug 2, 2021
https://docs.microsoft.com/en-us/windows/apps/design/app-settings/store-and-retrieve-app-data
NeilGirdhar commented on Aug 16, 2021
Why not just use appdirs as suggested in #12549?
StefRe commented on Nov 25, 2021
I think it should go into %LOCALAPPDATA%, not %APPDATA% which is for roaming app data. Cached fonts data are certainly not applicable on other devices. See also https://docs.microsoft.com/en-us/windows/win32/shell/knownfolderid.
StefRe commented on Nov 25, 2021
On Windows, the get_configdir and get_cachedir currently return the same value:
matplotlib/lib/matplotlib/__init__.py
Lines 467 to 472 in c072e3a
On Windows, I think we need to differentiate between %APPDATA% for roaming config data (get_configdir) and %LOCALAPPDATA% for local cache data (get_cachedir).
NeilGirdhar commented on Nov 26, 2021
@StefRe I think it should go into %LOCALAPPDATA%, not %APPDATA% which is for roaming app data.
appdirs already figures this out for you if you pass roaming=True: https://github.com/ActiveState/appdirs/blob/8eacfa312d77aba28d483fbfb6f6fc54099622be/appdirs.py#L165
StefRe commented on Nov 26, 2021
@NeilGirdhar Thanks for mentioning, but all I wanted to say was just what files should go to what folders, not how to obtain these folder locations.
StefRe commented on Nov 26, 2021
@tacaswell If we want to fix this particular issue #20779 for Windows, I can make a PR.
(Switching to appdirs #12549 is beyond me as I have no masOS or FreeBSD to test it and update the documention of get_configdir and get_cachedir. I couldn't find docs for appdirs (apart from the README file) that we could refer to for the details about folder selection on different OSs.)
NeilGirdhar commented on Nov 26, 2021
@StefRe Yes, I understand, but if you're going to fix this, I really think using appdirs is the right approach. They have already tested to make sure that their folder choices are correct. Otherwise, you'll just be fixing it for one OS for now, and it could easily break again one day. More importantly, the folders are messed up on all operating systems for the rest of us.
I also don't think it's that much harder to use appdirs than to do this manually. Just call appdirs.user_data_dir(appname='matplotlib', appauthor='matplotlib', version=..., roaming=False) and use that path.
2 remaining items
jkseppan commented on Jun 15, 2025
appdirs is now deprecated; the replacement is platformdirs
VedantMadane commented on Jan 16, 2026
Hi, I'd like to work on this issue. I'll implement the change to use \platformdirs\ (the maintained replacement for \�ppdirs) to properly place the matplotlib configuration and cache directories on Windows (%LOCALAPPDATA% for cache, %APPDATA% for config if roaming is desired, otherwise %LOCALAPPDATA%).
Use LOCALAPPDATA for config/cache directories on Windows
Use LOCALAPPDATA for config/cache directories on Windows
fix: Use LOCALAPPDATA for config/cache directories on Windows
fix: Use LOCALAPPDATA for config/cache directories on Windows (matplo…
NeilGirdhar commented on Mar 2, 2026
@timhoffm Could you please reopen the issue? This is only fixed on Windows, and in a very brittle way. Or perhaps we should open a separate issue for relying on platformdirs?
Human gold patch for matplotlib__matplotlib-30975