diff --git a/lib/matplotlib/__init__.py b/lib/matplotlib/__init__.py index f6b0e7669efa..8afd85c26d54 100644 --- a/lib/matplotlib/__init__.py +++ b/lib/matplotlib/__init__.py @@ -553,16 +553,14 @@ def _create_tmp_config_dir(): # Some restricted platforms (such as Google App Engine) do not provide # gettempdir. return None - try: username = getpass.getuser() except KeyError: username = str(os.getuid()) - tempdir = os.path.join(tempdir, 'matplotlib-%s' % username) - os.environ['MPLCONFIGDIR'] = tempdir + tempdir = tempfile.mkdtemp(prefix='matplotlib-%s-' % username, dir=tempdir) - mkdirs(tempdir) + os.environ['MPLCONFIGDIR'] = tempdir return tempdir