Repository navigation
Closed
Milestone
Description
Bug report
Bug summary
I am unable to import matplotlib.pyplot starting in version 3.0.0. Might be related to Issue #9485?
Code for reproduction
import matplotlib.pyplot as pltActual outcome
I get the following traceback when executing the above import
Traceback (most recent call last):
File "C:\Python\Python35\lib\site-packages\matplotlib\font_manager.py", line 1353, in <module>
fontManager = json_load(_fmcache)
File "C:\Python\Python35\lib\site-packages\matplotlib\font_manager.py", line 888, in json_load
with open(filename, 'r') as fh:
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\username\\.matplotlib\\fontlist-v300.json'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import matplotlib.pyplot as plt
File "C:\Python\Python35\lib\site-packages\matplotlib\pyplot.py", line 32, in <module>
import matplotlib.colorbar
File "C:\Python\Python35\lib\site-packages\matplotlib\colorbar.py", line 32, in <module>
import matplotlib.contour as contour
File "C:\Python\Python35\lib\site-packages\matplotlib\contour.py", line 18, in <module>
import matplotlib.font_manager as font_manager
File "C:\Python\Python35\lib\site-packages\matplotlib\font_manager.py", line 1363, in <module>
_rebuild()
File "C:\Python\Python35\lib\site-packages\matplotlib\font_manager.py", line 1344, in _rebuild
fontManager = FontManager()
File "C:\Python\Python35\lib\site-packages\matplotlib\font_manager.py", line 978, in __init__
ttffiles = findSystemFonts(paths) + findSystemFonts()
File "C:\Python\Python35\lib\site-packages\matplotlib\font_manager.py", line 264, in findSystemFonts
fontfiles.update(win32InstalledFonts(fontext=fontext))
TypeError: 'NoneType' object is not iterable
Matplotlib version
- Operating system: Windows 10 64-bit
- Matplotlib version: 3.0.0
- Matplotlib backend: TkAgg
- Python version: 3.5.4
- Jupyter version (if applicable): NA
- Other libraries: NA
Installed via pip
Metadata
Metadata
Assignees
Labels
No labels
Activity
FIX: maintain return type stability in win32InstalledFonts
dsentinel commentedon Sep 19, 2018
Same on a mac installed with conda if
~/.matplotlib/fontlist-v300.jsondoesn't existhangs.... ctl-c
~/.matplotlib/fontlist-v300.jsondidn't exist until I ran the import testing other versions (py27)MahdiEsf commentedon Sep 20, 2018
I have the same issue, the same error. matplotlib 3.00. Doesn't find fontlist-v300.json
tacaswell commentedon Sep 20, 2018
Not finding that file in fine, it is a cache and automatically re-generated.
Kojoley commentedon Sep 22, 2018
Output:
Added logging to
win32InstalledFonts:Output:
Details
So we have a problem...
'.ttf' in 'ttf'is of courseFalseKojoley commentedon Sep 22, 2018
There are more problem usages of
Path(...).suffix.Again the leading dot:
matplotlib/lib/matplotlib/font_manager.py
Line 158 in 2891f55
Will fire an exception when file has no extension/suffix
matplotlib/lib/matplotlib/font_manager.py
Line 245 in 07e2d54
font_manager: Fixed problems with Path(...).suffix
anntzer commentedon Sep 22, 2018
Thanks for investigating.
I don't think Path(fname).suffix[1:] will throw if there's no suffix though, as the suffix would be an empty string and [1:] on it will still be an empty string. We do need to make sure that fontext is a list of strings and not a single string though.
Kojoley commentedon Sep 22, 2018
Oops, that's something I had misconception, I thought
''[1:]will fire an index exception.anntzer commentedon Sep 22, 2018
For lists too you can pass an "invalid" slice and it'll just give you an empty list.
Kojoley commentedon Sep 22, 2018
#12212 will not solve the issue.
The
win32InstalledFontsreturnsNoneonly if regkeys are missing. Any thoughts?anntzer commentedon Sep 22, 2018
I think #12174 is just fine to handle this case. Perhaps we were just lucky not to have run into that before?
Kojoley commentedon Sep 22, 2018
#12174 is fine, but IIUC the reg key should always exist, may be the guys deleted it by hand or with some third party program?
anntzer commentedon Sep 22, 2018
I don't think we should overly bother about cases where well-documented regsitry keys are missing (i.e. I don't think we should try too hard to find the fonts in that case).
23 remaining items
Kojoley commentedon Oct 7, 2018
I have included links to wheels in my last post. You should be able to install one with
pip install path/to.whl. I thought you have done it already in #12173 (comment).danp-hh commentedon Oct 10, 2018
@Kojoley the wheel you provided for #12408 fixed that problem for me. I am using python 3.5.6 with Miniconda on Windows 10 64 Bit . Thanks!
drdavella commentedon Oct 18, 2018
Just experienced this issue in a conda environment with
mpl=3.0.0andpython=3.6.6on OSX. We stumbled across a workaround: move out of the home directory and run the offending code. After this, mpl creates the fonts file and things seem to work fine for subsequent runs.I guess this is the best workaround until this fix is released?
tacaswell commentedon Oct 18, 2018
@drdavella The OP here is a windows-specific bug (issues with getting keys out of the the windows registry) so I suspect you were seeing a different issue.
I am very confused by the report that changing what directory you are in making a difference, but if it does, that is almost certainly a bug we need to fix! Can you open a new issue with more detials (if you can still reproduce the issue).
drdavella commentedon Oct 18, 2018
@tacaswell, oops I guess I skimmed this a little too quickly! Yes I can still reproduce it, so I'll open a new issue presently.
UPDATE: See #12556
deansg commentedon Oct 19, 2018
Just wanted to add that as of today I can still reproduce it. Using Windows 10 with a 32-bit version of Python 3.5.2, installed mathplotlib via pip, and I get the exact same error when importing the module.
tacaswell commentedon Oct 19, 2018
@deansg That is expected, the fix is in the source but has not been released yet. The current plan is to release 3.0.1 around Nov 3.
deansg commentedon Oct 19, 2018
@tacaswell Alright, I wasn't sure about it because after reading the entire exchange, at one point the focus shifted to a (possibly different?) bug in OSX and I couldn't figure out what the current status is. Maybe it will be beneficial to include an explicit workaround in the description (such as downgrading to 2.2.3)?
erotavlas commentedon Nov 20, 2018
What is the solution for this?
I'm getting this error in conda environment using matplotlib v3.0.0
drdavella commentedon Nov 20, 2018
@erotavlas you should be able to install 3.0.1 using conda now.
erotavlas commentedon Nov 20, 2018
@drdavella it wont let me, either from the prompt (conda update matplotlib) or from the anaconda navigator...it says "All requested packaged already installed "
higgsch commentedon Jan 13, 2019
Just installed v3.0.2 and am getting the exact same error. Python 3.6.0. Windows 8.1.
wenzao commentedon Jan 14, 2019
Are you all getting v3.0.1 now? My conda still only has v3.0.0 (python 3.6.8).
Actually v3.0.0 has been working fine for me, until I did the following update recently, then I started to get this error:
The following packages will be UPDATED:
Update: I installed v.3.0.2 from conda-forge channel and the issue is fixed.
AncoraImparo commentedon Jan 20, 2019
Unfortunately, I have encountered the same issue just now. I needed seaborn because it seemed not be installed (oddly), so I ran
conda install seaborn
Next, I receive a warning that a newer conda version exists 4.5.12 while I was running 4.511. So I follow instructions to update that.
It all proceeds to downloading a number of packages including seaborn-0.9.0 and matplotlib-3.0.0
while sip will be downgraded.
All funky, apparently, until I run import matplotlib and I get the error:
about fontlist-v300.json.
I'm now stuck without a functioning matplotlib. To fix this problem, I try this:
conda install -c conda-forge matplotlib
Same problem and worse because it wants to now downgrade a ton of packages. I rejected this install.
What do I do now?
band-a-prend commentedon Mar 19, 2020
This issue is still reproduced for me on gentoo linux for python 3.6.10 + matplotlib 3.1.2 with error about no such file in "/home/user/.cache/matplotlib/fontlist-v310.json"