-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
FileNotFoundError while import matplotlib (maybe pyplot) #9485
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I maybe solve this problem. In font_manager.py, line 240: try:
key, direc, any = winreg.EnumValue( local, j)
if not isinstance(direc, six.string_types):
continue
if not os.path.dirname(direc):
direc = os.path.join(directory, direc)
# Comment out these 3 lines
# direc = os.path.abspath(direc).lower()
# if os.path.splitext(direc)[1][1:] in fontext:
# items[direc] = 1
# and add following one line
direc = direc.split('\0', 1)[0]
except EnvironmentError:
continue
except WindowsError:
continue
except MemoryError:
continue Now it seems work perfectly, but I'm not sure the problem is really solved. |
I am almost certain I have already seen this issue reported, but can't find it anymore... |
|
The While that patch runs, I am not sure it runs properly. The @dasolyn Thanks for digging into this! |
The relevant docs(?) https://technet.microsoft.com/en-us/library/cc976493.aspx does not suggest anything about null bytes... |
|
I guess dropping the part about the null byte should be good enough. However, just to be sure, can you print each value of 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 |
for j in range(winreg.QueryInfoKey(local)[1]):
try:
key, direc, any = winreg.EnumValue( local, j)
if not isinstance(direc, six.string_types):
continue
if not os.path.dirname(direc):
direc = os.path.join(directory, direc)
print('j={}, key={}, direc={}, any={}, null={}'.format(j, key, direc, any, '\0' in direc))
if '\0' in direc:
direc = direc.split('\0', 1)[0]
direc = os.path.abspath(direc).lower()
if os.path.splitext(direc)[1][1:] in fontext:
items[direc] = 1
except EnvironmentError:
continue
except WindowsError:
continue
except MemoryError:
continue Result: https://pastebin.com/bFQe3SZh Only |
I still do not understand where the null char comes from. |
Found it: it's a bug in CPython itself... reported by a mpl user :-) https://bugs.python.org/issue25778 |
This is a 3.5-only bug as well. |
3.6.0 is definitely affected; probably 3.4 (https://bugs.python.org/issue25778#msg257316) too. |
Just upgraded Versions Code to reproduce This will produce a similar, but not identical stacktrace to the OP
We have pinned back to |
@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 🐛 . |
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 # KNOWN ISSUES
#
# - documentation
# - font variant is untested
# - font stretch is incomplete
# - font size is incomplete
# - default font algorithm needs improvement and testing
# - setWeights function needs improvement
# - 'light' is an invalid weight value, remove it.
# - update_fonts not implemented
def findSystemFonts(fontpaths=None, fontext='ttf'):
"""
Search for fonts in the specified font paths. If no paths are
given, will use a standard set of system paths, as well as the
list of fonts tracked by fontconfig if fontconfig is installed and
available. A list of TrueType fonts are returned by default with
AFM fonts as an option.
"""
fontfiles = set()
fontexts = get_fontext_synonyms(fontext)
if fontpaths is None:
if sys.platform == 'win32':
fontpaths = [win32FontDirectory()]
# now get all installed fonts directly...
fontfiles.update(win32InstalledFonts(fontext=fontext))
else:
fontpaths = X11FontDirectories
fontfiles.update(get_fontconfig_fonts(fontext))
# check for OS X & load its fonts if present
if sys.platform == 'darwin':
fontfiles.update(OSXInstalledFonts(fontext=fontext))
elif isinstance(fontpaths, str):
fontpaths = [fontpaths]
for path in fontpaths:
fontfiles.update(map(os.path.abspath, list_fonts(path, fontexts)))
return [fname for fname in fontfiles if os.path.exists(fname)] |
Please advise |
@DrDeviprasad please follow to the #12173 issue |
Bug report
Traceback
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
I installed matplotlib via pip.
The text was updated successfully, but these errors were encountered: