Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 31fa2b2

Browse files
committed
Merge pull request #5954 from cancan101/patch-1
Fix issues with getting tempdir when unknown uid
1 parent d4ee801 commit 31fa2b2

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

lib/matplotlib/__init__.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,13 @@ def _create_tmp_config_dir():
552552
# Some restricted platforms (such as Google App Engine) do not provide
553553
# gettempdir.
554554
return None
555-
tempdir = os.path.join(tempdir, 'matplotlib-%s' % getpass.getuser())
555+
556+
try:
557+
username = getpass.getuser()
558+
except KeyError:
559+
username = str(os.getuid())
560+
tempdir = os.path.join(tempdir, 'matplotlib-%s' % username)
561+
556562
os.environ['MPLCONFIGDIR'] = tempdir
557563

558564
mkdirs(tempdir)

0 commit comments

Comments
 (0)