-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
UnicodeDecodeError: 'ascii' codec can't decode byte 0x8e in position 20: ordinal not in range(128) #9196
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
@javadr Sorry you are having this issue and thank you for reporting it. This should be reported to Fedora to update their packaged version. |
Appreciate your concern and your fast reply. I updated the |
8000
Most likely, you have to clear out the old installation and reinstall the
new version.
…On Mon, Sep 18, 2017 at 3:43 AM, javadr ***@***.***> wrote:
Appreciate your concern and your fast reply.
I updated the matplotlib to 2.1.0rc1 with pip, but the problem not solved
yet. :(
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#9196 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AARy-Mm82ILp2rXYOk5Vx-ClPd69WHNMks5sjh81gaJpZM4PaITb>
.
|
@javadr can you drop into the debugger and determine which file it is failing on? I was wrong, this is a different bug and the this decode is still on line 192 in afm.py |
thanks again, I hope that the following output help you. Python 2.7.13 (default, Sep 5 2017, 08:53:59)
[GCC 7.1.1 20170622 (Red Hat 7.1.1-3)] on linux2
Type "copyright", "credits" or "license()" for more information.
>>> import matplotlib.pyplot
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import matplotlib.pyplot
File "/usr/lib64/python2.7/site-packages/matplotlib/pyplot.py", line 29, in <module>
import matplotlib.colorbar
File "/usr/lib64/python2.7/site-packages/matplotlib/colorbar.py", line 36, in <module>
import matplotlib.contour as contour
File "/usr/lib64/python2.7/site-packages/matplotlib/contour.py", line 22, in <module>
import matplotlib.font_manager as font_manager
File "/usr/lib64/python2.7/site-packages/matplotlib/font_manager.py", line 1439, in <module>
_rebuild()
File "/usr/lib64/python2.7/site-packages/matplotlib/font_manager.py", line 1418, in _rebuild
fontManager = FontManager()
File "/usr/lib64/python2.7/site-packages/matplotlib/font_manager.py", line 1072, in __init__
self.afmlist = createFontList(self.afmfiles, fontext='afm')
File "/usr/lib64/python2.7/site-packages/matplotlib/font_manager.py", line 583, in createFontList
font = afm.AFM(fh)
File "/usr/lib64/python2.7/site-packages/matplotlib/afm.py", line 349, in __init__
parse_afm(fh)
File "/usr/lib64/python2.7/site-packages/matplotlib/afm.py", line 337, in parse_afm
dcmetrics_ascii, dcmetrics_name = _parse_char_metrics(fh)
File "/usr/lib64/python2.7/site-packages/matplotlib/afm.py", line 198, in _parse_char_metrics
line = line.rstrip().decode('ascii') # Convert from byte-literal
UnicodeDecodeError: 'ascii' codec can't decode byte 0x8e in position 20: ordinal not in range(128) P.S. Python 3.6.2 (default, Aug 11 2017, 11:59:59)
[GCC 7.1.1 20170622 (Red Hat 7.1.1-3)] on linux
Type "copyright", "credits" or "license()" for more information.
>>> import matplotlib.pyplot
Traceback (most recent call last):
File "/usr/lib64/python3.6/site-packages/matplotlib/font_manager.py", line 1429, in <module>
fontManager = pickle_load(_fmcache)
File "/usr/lib64/python3.6/site-packages/matplotlib/font_manager.py", line 965, in pickle_load
with open(filename, 'rb') as fh:
FileNotFoundError: [Errno 2] No such file or directory: '/home/javad/.cache/matplotlib/fontList.py3k.cache'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import matplotlib.pyplot
File "/usr/lib64/python3.6/site-packages/matplotlib/pyplot.py", line 29, in <module>
import matplotlib.colorbar
File "/usr/lib64/python3.6/site-packages/matplotlib/colorbar.py", line 36, in <module>
import matplotlib.contour as contour
File "/usr/lib64/python3.6/site-packages/matplotlib/contour.py", line 22, in <module>
import matplotlib.font_manager as font_manager
File "/usr/lib64/python3.6/site-packages/matplotlib/font_manager.py", line 1439, in <module>
_rebuild()
File "/usr/lib64/python3.6/site-packages/matplotlib/font_manager.py", line 1418, in _rebuild
fontManager = FontManager()
File "/usr/lib64/python3.6/site-packages/matplotlib/font_manager.py", line 1072, in __init__
self.afmlist = createFontList(self.afmfiles, fontext='afm')
File "/usr/lib64/python3.6/site-packages/matplotlib/font_manager.py", line 583, in createFontList
font = afm.AFM(fh)
File "/usr/lib64/python3.6/site-packages/matplotlib/afm.py", line 349, in __init__
parse_afm(fh)
File "/usr/lib64/python3.6/site-packages/matplotlib/afm.py", line 337, in parse_afm
dcmetrics_ascii, dcmetrics_name = _parse_char_metrics(fh)
File "/usr/lib64/python3.6/site-packages/matplotlib/afm.py", line 198, in _parse_char_metrics
line = line.rstrip().decode('ascii') # Convert from byte-literal
UnicodeDecodeError: 'ascii' codec can't decode byte 0x8e in position 20: ordinal not in range(128) |
This is so weird, I've also installed Anaconda2 and I've got the same error! Python 2.7.13 |Anaconda 4.4.0 (64-bit)| (default, Dec 20 2016, 23:09:15)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://anaconda.org
>>> import matplotlib.pyplot
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/javad/anaconda2/lib/python2.7/site-packages/matplotlib/pyplot.py", line 29, in <module>
import matplotlib.colorbar
File "/home/javad/anaconda2/lib/python2.7/site-packages/matplotlib/colorbar.py", line 36, in <module>
import matplotlib.contour as contour
File "/home/javad/anaconda2/lib/python2.7/site-packages/matplotlib/contour.py", line 22, in <module>
import matplotlib.font_manager as font_manager
File "/home/javad/anaconda2/lib/python2.7/site-packages/matplotlib/font_manager.py", line 1439, in <module>
_rebuild()
File "/home/javad/anaconda2/lib/python2.7/site-packages/matplotlib/font_manager.py", line 1418, in _rebuild
fontManager = FontManager()
File "/home/javad/anaconda2/lib/python2.7/site-packages/matplotlib/font_manager.py", line 1072, in __init__
self.afmlist = createFontList(self.afmfiles, fontext='afm')
File "/home/javad/anaconda2/lib/python2.7/site-packages/matplotlib/font_manager.py", line 583, in createFontList
font = afm.AFM(fh)
File "/home/javad/anaconda2/lib/python2.7/site-packages/matplotlib/afm.py", line 349, in __init__
parse_afm(fh)
File "/home/javad/anaconda2/lib/python2.7/site-packages/matplotlib/afm.py", line 337, in parse_afm
dcmetrics_ascii, dcmetrics_name = _parse_char_metrics(fh)
File "/home/javad/anaconda2/lib/python2.7/site-packages/matplotlib/afm.py", line 198, in _parse_char_metrics
line = line.rstrip().decode('ascii') # Convert from byte-literal
UnicodeDecodeError: 'ascii' codec can't decode byte 0x8e in position 20: ordinal not in range(128) I don't know is it something wrong with fedora 26 or not?! |
I found the problem, It was because of my installed fonts! I removed some of them and now I can use Sorry to cause you inconvenience. |
@javadr which font (that is what I meant by 'which file' above, sorry for being unclear!)? I am interested in looking at exactly what it has inside to understand why this is happening. We should be able to handle, or at least gracefully fail, on (possibly) malformed font! |
Unfortunately, I removed many fonts, and now I don't know which one caused the problem , but if I find that problematic font, I'll send it. |
Thanks @javadr . Glad things are working for you again! |
Does it work if you replace the line
by
? Reopening although the issue is kind of different, but that's fine. |
Hello anntzer,
It makes no difference. Just to be accurate, the following pic : is the Error I get if running the script with a ipython console launched from the path window : Here is the mistake I get in the Python console of Pycharm : I will try to go further in the comments of #10044 |
You edited What about the other proposed fix of using |
Yes I have firstly edited the script with your proposed fixture using b' File ...' |
I've got the same problem. On Debian Buster with matplotlib 2.2.2. To address this problem I recommend to use traceback2, that always returns list of 'unicode'. Change is simple: replace 'import traceback' with 'import traceback2 as traceback' in matplotlib/backends/init.py |
The code path in question no longer exists on master branch / 3.0 branch. This is a python2 only issue and mpl3.0+ will not support python2. @AndreySV I am skeptical of picking up a new dependency on a micro release (ex 2.2.4). Does _backend_loading_tb = b"".join(
line for line in traceback.format_stack()
# Filter out line noise from importlib line.
if not line.startswith(b' File "<frozen importlib._bootstrap')) fix the problem? In either case, can you open a new issue for this issue which is an entirely different issue than the original. |
Yes, convert to bytes both strings helps. I've opened for that separate issue #11955 |
I'm going to re-close this it is really two issues, the first of which is already fixed and the second of which now has it's own issue. |
Before import matplotlib.pyplot, you can use the following code. |
Uh oh!
There was an error while loading. Please reload this page.
Bug report
When I want to use
pyplot
frommatplotlib
, it causes error.There is no problem with
import matplotlib
but I cannot usepyplot
Code for reproduction
Actual outcome
Expected outcome
using
%matplotlib
magic injupyter notebook
also produces the same error.Matplotlib version
The text was updated successfully, but these errors were encountered: