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
fail to import matplotlib.pyplot #2320
Comments
It's having trouble reading the information from a particular font, probably because it doesn't contain the Macintosh SFNT tables (which was the defacto "standard" until recently when Microsoft started releasing fonts without them). The ongoing MEP14 should resolve these sorts of errors. Before that is done, it should probably be possible to get past this by decoding using utf16be for these particular fonts only. I'm on vacation this week -- just wanted to notate the problem in case anyone else is able to get to it first. |
An interesting observation... the line numbers from those traceback statements lines up perfectly with the original source code in the git repository. Why is this strange, you ask? Because we still target py2.6 as we code, and py3k installs are supposed to go through 2to3 (or is it six now?), which invariably messes around a bit with adding new lines of code and such. Furthermore, the error has to do with unicode handling, which is what 2to3 typically tries to fix in most of our codebase. |
I think I am running into the same problem (Python 2.7.5) after updating matplotlib to new version 1.3.0 (also, it seems to me this report comes from the same issue:http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=719065 ). The cause seems to be by a non-ascii character in a font name:
I noticed that the only change from v1.2.1 to master is the |
@megies: Where is the From either @megies or @matthiasdresden: it would be helpful to know which font file is causing this failure. Can you put |
@megies, @matthiasdresden: Would you mind checking the patch in #2320 to see if it resolves your issue? |
Sorry if that was confusing, I put it there myself to debug this (and that was the only change in the code). As for the font, I'll look it up tomorrow. |
This is the font its struggling with (last line of debug output before the Exception):
The font is directly available on the debian sources server:
The character causing this seems to be |
Thanks. That's coincidentally the same font that was tripping someone up in #2307. Are you able to check out that PR to test? |
Oh right, forgot about trying the PR.. Tried it now and it works fine! |
Closed by #2307. |
Great. Thanks for the fix. |
This patch results in botched font name for EPSON family fonts, available here: http://www.epson.jp/download2/printer/driver/win/page/ttf30.htm. I found that apparently their names are encoded in I personally don't care about using these fonts in matplotlib, but you might be interested in replicating fontconfig behavior for other users. |
@liori: Wow. That's crappy. If the fonts are violating the spec, they're violating the spec. I don't know how far down the road I want to go of adding heuristics so support what are essentially broken fonts. We could do better at skipping over them, however. That's really what I think I'd prefer to do. |
Closing. Already fixed in master. |
Just gonna put out there I ran into this just recently with conda 4.3.29 and python 3.6 on windows 10. |
@drcrook1 please open a new issue. |
I have found the following problem:
I tried a new Installation of Python 3.3.2 64-bit with WinPython-64bit-3.3.2.2 on a Windows 7 64 bit machine.
Ever when I try to import matplotlib.pyplot (with some of my user accounts i use on this Windows-7 machine) I get tthe following error message:
Traceback (most recent call last):
File "D:\WinPython_3.3.2.2\python-3.3.2.amd64\lib\site-packages\matplotlib\font_manager.py", line 1348, in
fontManager = pickle_load(_fmcache)
File "D:\WinPython_3.3.2.2\python-3.3.2.amd64\lib\site-packages\matplotlib\font_manager.py", line 947, in pickle_load
with open(filename, 'rb') as fh:
FileNotFoundError: [Errno 2] No such file or directory: 'C:\Users\Jobst3.matplotlib\fontList.py3k.cache'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "", line 1, in
File "D:\WinPython_3.3.2.2\python-3.3.2.amd64\lib\site-packages\matplotlib\pyplot.py", line 24, in
import matplotlib.colorbar
File "D:\WinPython_3.3.2.2\python-3.3.2.amd64\lib\site-packages\matplotlib\colorbar.py", line 29, in
import matplotlib.collections as collections
File "D:\WinPython_3.3.2.2\python-3.3.2.amd64\lib\site-packages\matplotlib\collections.py", line 23, in
import matplotlib.backend_bases as backend_bases
File "D:\WinPython_3.3.2.2\python-3.3.2.amd64\lib\site-packages\matplotlib\backend_bases.py", line 50, in
import matplotlib.textpath as textpath
File "D:\WinPython_3.3.2.2\python-3.3.2.amd64\lib\site-packages\matplotlib\textpath.py", line 11, in
import matplotlib.font_manager as font_manager
File "D:\WinPython_3.3.2.2\python-3.3.2.amd64\lib\site-packages\matplotlib\font_manager.py", line 1356, in
_rebuild()
File "D:\WinPython_3.3.2.2\python-3.3.2.amd64\lib\site-packages\matplotlib\font_manager.py", line 1341, in _rebuild
fontManager = FontManager()
File "D:\WinPython_3.3.2.2\python-3.3.2.amd64\lib\site-packages\matplotlib\font_manager.py", line 1004, in init
self.ttflist = createFontList(self.ttffiles)
File "D:\WinPython_3.3.2.2\python-3.3.2.amd64\lib\site-packages\matplotlib\font_manager.py", line 584, in createFontList
prop = ttfFontProperty(font)
File "D:\WinPython_3.3.2.2\python-3.3.2.amd64\lib\site-packages\matplotlib\font_manager.py", line 398, in ttfFontProperty
sfnt4 = sfnt4.decode('ascii').lower()
UnicodeDecodeError: 'ascii' codec can't decode byte 0x82 in position 0: ordinal not in range(128)
The same issue happens with other python version (3.2.3 64 bit, as I installed matplotlib 1.3. with easy install).
I found out that this happens only with newly created user accounts, but not with older accounts. As I found out, python is looking for a file located in the user folder: C:\Users\Jobst3.matplotlib\fontList.py3k.cache' which is not there in the newly created user account.
But the file is available in older user accounts. The file was created by an older version of matplotlib (matplotlib-1.2.0rc2.win-amd64-py3.2), and everything goes fine, if i use these accounts.
I am not able to test the issue on a complete new and clean Windows-7 machine at the moment
Matthias
The text was updated successfully, but these errors were encountered: