-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
savefig to pdf: 'str' object has no attribute 'decode' #6516
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 get different errors, but I assume I am missing the required russian specific tex packages. Can you drop into the debugger and get what the font name is? It looks like this is a work-around to getting bytestrings that need to be decoded to attn @mdboom |
also @jkseppan |
I'm guessing that the Cyrillic font does not have an entry in pdftex.map, which would make this another instance of #4167. |
I've tried the same code under Python 2.7 and got another error:
larm1200 that's the font name |
FWIW, I've got TeX Live 2015 on OS X 10.11. The font called larm1200 by TeX is supplied in the file sfrm1200.pfb.
@horribleheffalump: Do you have an entry for larm1200 in pdftex.map? Is there a corresponding pfa or pfb file? |
@jkseppan Yes! That was the problem. I've installed sfrm1200.pfb as a part of cm-super package, and now it all works fine. Thank you! |
The following script is giving me the same error:
Which produces the following error:
However, I am not using any special characters except [ '%', '$'], which I have escaped. The figure will show fine on the console. The error occurs when I attempt to save as a .pdf. Matplotlib 1.5.1, Python 3.4, OS Windows 7 |
Dvi is a binary format that includes some ASCII strings such as TeX names of some fonts. The associated files such as psfonts.map need to be ASCII too. This patch changes their handling to keep them as binary strings all the time. This avoids the ugly workaround try: result = some_mapping[texname] except KeyError: result = some_mapping[texname.decode('ascii')] which is essentially saying that texname is sometimes a string, sometimes a bytestring. The workaround masks real KeyErrors, leading to incomprehensible error messages such as in matplotlib#6516.
So if you follow the troubleshooting instructions and rerun with --verbose-helpful you get a hint about the usual reason for matplotlib#6516.
See pull request #6977 for a fix that improves the error message so you know which font is missing. You probably need to install some PS font package in your TeX package manager. |
Dvi is a binary format that includes some ASCII strings such as TeX names of some fonts. The associated files such as psfonts.map need to be ASCII too. This patch changes their handling to keep them as binary strings all the time. This avoids the ugly workaround try: result = some_mapping[texname] except KeyError: result = some_mapping[texname.decode('ascii')] which is essentially saying that texname is sometimes a string, sometimes a bytestring. The workaround masks real KeyErrors, leading to incomprehensible error messages such as in matplotlib#6516.
So if you follow the troubleshooting instructions and rerun with --verbose-helpful you get a hint about the usual reason for matplotlib#6516.
Dvi is a binary format that includes some ASCII strings such as TeX names of some fonts. The associated files such as psfonts.map need to be ASCII too. This patch changes their handling to keep them as binary strings all the time. This avoids the ugly workaround try: result = some_mapping[texname] except KeyError: result = some_mapping[texname.decode('ascii')] which is essentially saying that texname is sometimes a string, sometimes a bytestring. The workaround masks real KeyErrors, leading to incomprehensible error messages such as in matplotlib#6516.
So if you follow the troubleshooting instructions and rerun with --verbose-helpful you get a hint about the usual reason for matplotlib#6516.
This was fixed by #6977 and went out with 2.1 |
The following script:
works fine and shows the figure, but saving to pdf results in the following error:
The error arises only if cyrillic letters are used in labels.
Matplotlib 1.5.1, Python 3.5, OS Windows 10
Stackoverflow question link
The text was updated successfully, but these errors were encountered: