Repository navigation
Description
Bug report
Bug summary
When importing matplotlib.pyplot, the interpreter hangs indefinitely. This only seems to happen in an environment where $HOME/.matplotlib does not yet exist. I reproduced this in my environment by renaming the existing$HOME/.matplotlib directory. Critically, this only seems to occur when running the script from $HOME.
A valid workaround seems to be to move to any other directory and run the same command. After this, a new .matplotlib/ directory now exists in $HOME, and the previous command works fine when running from $HOME.
In order to reproduce this I created a conda environment with the following command:
$ conda create -n mpl-test python ipython matplotlib
Everything came from the default channel.
Code for reproduction
from matplotlib import pytplot as pltActual outcome
This hangs indefinitely. When I hit CTRL-C, I get something like the following:
~/miniconda3/envs/mpl-test/lib/python3.7/site-packages/matplotlib/pyplot.py in <module>
30 from cycler import cycler
31 import matplotlib
---> 32 import matplotlib.colorbar
33 import matplotlib.image
34 from matplotlib import rcsetup, style
~/miniconda3/envs/mpl-test/lib/python3.7/site-packages/matplotlib/colorbar.py in <module>
30 import matplotlib.collections as collections
31 import matplotlib.colors as colors
---> 32 import matplotlib.contour as contour
33 import matplotlib.cm as cm
34 import matplotlib.gridspec as gridspec
~/miniconda3/envs/mpl-test/lib/python3.7/site-packages/matplotlib/contour.py in <module>
16 import matplotlib.colors as mcolors
17 import matplotlib.collections as mcoll
---> 18 import matplotlib.font_manager as font_manager
19 import matplotlib.text as text
20 import matplotlib.cbook as cbook
~/miniconda3/envs/mpl-test/lib/python3.7/site-packages/matplotlib/font_manager.py in <module>
1361 raise
1362 except Exception:
-> 1363 _rebuild()
1364 else:
1365 _rebuild()
~/miniconda3/envs/mpl-test/lib/python3.7/site-packages/matplotlib/font_manager.py in _rebuild()
1342 global fontManager
1343
-> 1344 fontManager = FontManager()
1345
1346 if _fmcache:
~/miniconda3/envs/mpl-test/lib/python3.7/site-packages/matplotlib/font_manager.py in __init__(self, size, weight)
976 self.defaultFont = {}
977
--> 978 ttffiles = findSystemFonts(paths) + findSystemFonts()
979 self.defaultFont['ttf'] = next(
980 (fname for fname in ttffiles
~/miniconda3/envs/mpl-test/lib/python3.7/site-packages/matplotlib/font_manager.py in findSystemFonts(fontpaths, fontext)
268 # check for OS X & load its fonts if present
269 if sys.platform == 'darwin':
--> 270 fontfiles.update(OSXInstalledFonts(fontext=fontext))
271
272 elif isinstance(fontpaths, str):
~/miniconda3/envs/mpl-test/lib/python3.7/site-packages/matplotlib/font_manager.py in OSXInstalledFonts(directories, fontext)
216 directories = OSXFontDirectories
217 return [path
--> 218 for directory in directories
219 for ext in get_fontext_synonyms(fontext)
220 for path in list_fonts(directory, ext)]
~/miniconda3/envs/mpl-test/lib/python3.7/site-packages/matplotlib/font_manager.py in <listcomp>(.0)
218 for directory in directories
219 for ext in get_fontext_synonyms(fontext)
--> 220 for path in list_fonts(directory, ext)]
221
222
~/miniconda3/envs/mpl-test/lib/python3.7/site-packages/matplotlib/font_manager.py in list_fonts(directory, extensions)
155 extensions = ["." + ext for ext in extensions]
156 return [str(path)
--> 157 for path in filter(Path.is_file, Path(directory).glob("**/*.*"))
158 if path.suffix in extensions]
159
~/miniconda3/envs/mpl-test/lib/python3.7/site-packages/matplotlib/font_manager.py in <listcomp>(.0)
154 """
155 extensions = ["." + ext for ext in extensions]
--> 156 return [str(path)
157 for path in filter(Path.is_file, Path(directory).glob("**/*.*"))
158 if path.suffix in extensions]
~/miniconda3/envs/mpl-test/lib/python3.7/pathlib.py in glob(self, pattern)
1080 raise NotImplementedError("Non-relative patterns are unsupported")
1081 selector = _make_selector(tuple(pattern_parts))
-> 1082 for p in selector.select_from(self):
1083 yield p
1084
~/miniconda3/envs/mpl-test/lib/python3.7/pathlib.py in _select_from(self, parent_path, is_dir, exists, scandir)
543 for starting_point in self._iterate_directories(parent_path, is_dir, scandir):
544 for p in successor_select(starting_point, is_dir, exists, scandir):
--> 545 if p not in yielded:
546 yield p
547 yielded.add(p)
~/miniconda3/envs/mpl-test/lib/python3.7/pathlib.py in __hash__(self)
724 return self._hash
725 except AttributeError:
--> 726 self._hash = hash(tuple(self._cparts))
727 return self._hash
728
~/miniconda3/envs/mpl-test/lib/python3.7/pathlib.py in _cparts(self)
710 # Cached casefolded parts, for hashing and comparison
711 try:
--> 712 return self._cached_cparts
713 except AttributeError:
714 self._cached_cparts = self._flavour.casefold_parts(self._parts)
KeyboardInterrupt:
Expected outcome
It shouldn't hang! 😝
Matplotlib version
- Operating system: OSX 10.12.6 (High Sierra)
- Matplotlib version: 3.0.0
- Matplotlib backend (
print(matplotlib.get_backend())): This command hangs also, but after performing the workaround I get'TkAgg' - Python version: 3.7.0, but we initially saw this on 3.6.6.
- Jupyter version (if applicable): N/A
- Other libraries: The only other thing installed in this environment is IPython
cc @brechmos-stsci who initially encountered this issue and discovered the workaround.
Activity
WeatherGod commentedon Oct 18, 2018
jklymak commentedon Oct 18, 2018
Yes, this has been fixed... #12177 which closed #12176.
Please reopen if you think your issue is different.
drdavella commentedon Oct 18, 2018
Just curious but when will this fix be released?
ImportanceOfBeingErnest commentedon Oct 18, 2018
Current plan is for the 3.0.1 release to happen first week of november. As a rough estimate.
But feel free to already test now with the current development branch.