Repository navigation
Closed
Labels
Milestone
Description
Bug report
Traceback
Traceback (most recent call last):
File "C:\Users\hanso\AppData\Local\Programs\Python\Python35\lib\site-packages\matplotlib\font_manager.py", line 1444, in <module>
fontManager = json_load(_fmcache)
File "C:\Users\hanso\AppData\Local\Programs\Python\Python35\lib\site-packages\matplotlib\font_manager.py", line 973, in json_load
with open(filename, 'r') as fh:
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\hanso\\.matplotlib\\fontList.json'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:/Users/hanso/PycharmProjects/reinforcement-learning-kr/2-cartpole/1-dqn/cartpole_dqn.py", line 3, in <module>
import pylab
File "C:\Users\hanso\AppData\Local\Programs\Python\Python35\lib\site-packages\pylab.py", line 1, in <module>
from matplotlib.pylab import *
File "C:\Users\hanso\AppData\Local\Programs\Python\Python35\lib\site-packages\matplotlib\pylab.py", line 257, in <module>
from matplotlib import cbook, mlab, pyplot as plt
File "C:\Users\hanso\AppData\Local\Programs\Python\Python35\lib\site-packages\matplotlib\pyplot.py", line 29, in <module>
import matplotlib.colorbar
File "C:\Users\hanso\AppData\Local\Programs\Python\Python35\lib\site-packages\matplotlib\colorbar.py", line 36, in <module>
import matplotlib.contour as contour
File "C:\Users\hanso\AppData\Local\Programs\Python\Python35\lib\site-packages\matplotlib\contour.py", line 21, in <module>
import matplotlib.font_manager as font_manager
File "C:\Users\hanso\AppData\Local\Programs\Python\Python35\lib\site-packages\matplotlib\font_manager.py", line 1454, in <module>
_rebuild()
File "C:\Users\hanso\AppData\Local\Programs\Python\Python35\lib\site-packages\matplotlib\font_manager.py", line 1434, in _rebuild
fontManager = FontManager()
File "C:\Users\hanso\AppData\Local\Programs\Python\Python35\lib\site-packages\matplotlib\font_manager.py", line 1060, in __init__
self.ttffiles = findSystemFonts(paths) + findSystemFonts()
File "C:\Users\hanso\AppData\Local\Programs\Python\Python35\lib\site-packages\matplotlib\font_manager.py", line 323, in findSystemFonts
for f in win32InstalledFonts(fontdir):
File "C:\Users\hanso\AppData\Local\Programs\Python\Python35\lib\site-packages\matplotlib\font_manager.py", line 240, in win32InstalledFonts
direc = os.path.abspath(direc).lower()
File "C:\Users\hanso\AppData\Local\Programs\Python\Python35\lib\ntpath.py", line 535, in abspath
path = _getfullpathname(path)
ValueError: _getfullpathname: embedded null character
And I couldn't find C:\Users\hanso\.matplotlib\fontList.json
Code for reproduction
https://github.com/rlcode/reinforcement-learning-kr/blob/master/2-cartpole/1-dqn/cartpole_dqn.py
Matplotlib version
- Operating system: Windows 10 64bit 1703
- Matplotlib version: 2.1.0
- Matplotlib backend : TkAgg
- Python version: 3.5.4
I installed matplotlib via pip.
Activity
ha-nso-li commentedon Oct 20, 2017
I maybe solve this problem.
In font_manager.py, line 240:
Now it seems work perfectly, but I'm not sure the problem is really solved.
anntzer commentedon Oct 20, 2017
I am almost certain I have already seen this issue reported, but can't find it anymore...
In any case, can you print what is the value of
direcjust before the part you commented out?ha-nso-li commentedon Oct 20, 2017
@anntzer
print(direc)showsC:\\WINDOWS\\Fonts\\HYHWPEQ.TTF HyhwpEQbut the space is
'\0'(null character) not whitespace.tacaswell commentedon Oct 20, 2017
The
FileNoteFounderror is expected (that is how we know if we need to rebuild the font cache). The bug is we are not paranoid enough in the handling of the paths that come back from windows.While that patch runs, I am not sure it runs properly. The
itemsdictionary which is being built up is finally returned as a list of font files. This effectively disables this method of finding fonts!@dasolyn Thanks for digging into this!
anntzer commentedon Oct 20, 2017
Can you look up what values does your windows registry report for the keys "SOFTWARE\Microsoft\Windows\CurrentVersion\Fonts" and "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts".
Does "C:\WINDOWS\Fonts\HYHWPEQ.TTF" actually exist in your filesystem?
What does
reg QUERY "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fontsat the command line give you?The relevant docs(?) https://technet.microsoft.com/en-us/library/cc976493.aspx does not suggest anything about null bytes...
ha-nso-li commentedon Oct 20, 2017
@anntzer
\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Fontsdoesn't exist.\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fontshas lots of string values, including HyhwpEQ.Yes

It has 554 lines. https://pastebin.com/hSJG5g7J
anntzer commentedon Oct 20, 2017
I guess dropping the part about the null byte should be good enough. However, just to be sure, can you print each value of
direcin the loop (as it comes out of winreg.EnumValue)? I just want to see whether there are funky things other than null bytes...In fact this looks like a bug in cpython's winreg: REG_SZ is documented as a "null terminated string" (https://msdn.microsoft.com/en-us/library/windows/desktop/ms724884(v=vs.85).aspx and https://docs.python.org/3/library/winreg.html#winreg.REG_SZ), so the returned value should stop at the first null. Or perhaps not... maybe it means terminated by a utf-16 null, i.e. two null bytes. See https://github.com/python/cpython/blob/master/PC/winreg.c#L719
ha-nso-li commentedon Oct 21, 2017
@anntzer
Result: https://pastebin.com/bFQe3SZh
Only
hyhwpeq.ttfhas a null character. Others are OK. (maybe?)Kojoley commentedon Oct 21, 2017
I still do not understand where the null char comes from.
Could you please dump and upload the registry?
reg export "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts" fontsdump.reganntzer commentedon Oct 21, 2017
Found it: it's a bug in CPython itself... reported by a mpl user :-) https://bugs.python.org/issue25778
tacaswell commentedon Oct 21, 2017
This is a 3.5-only bug as well.
anntzer commentedon Oct 21, 2017
3.6.0 is definitely affected; probably 3.4 (https://bugs.python.org/issue25778#msg257316) too.
Cory-Kramer commentedon Sep 19, 2018
Just upgraded
matplotlibfrom2.2.3to3.0.0and ran into this exact same issue.Versions
Operating system: Windows 10 64bit
Matplotlib version: 3.0.0
Python version: 3.5.4
Code to reproduce
import matplotlib.pyplot as pltThis will produce a similar, but not identical stacktrace to the OP
We have pinned back to
2.2.3until a fix or workaround is available.tacaswell commentedon Sep 19, 2018
@Cory-Kramer Can you open a new issue for this? This was fixed in 2.1.1 so the breaking between 2.2.3 and 3.0 is a new 🐛 .
DrDeviprasad commentedon Sep 22, 2018
Even after installing the latest version of matplotlib, this is not working. From the above comments it looks like an bug, doesn't seem to fixed in the code
DrDeviprasad commentedon Sep 22, 2018
Please advise
Kojoley commentedon Sep 22, 2018
@DrDeviprasad please follow to the #12173 issue