Skip to content
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

import matplotlib causes UnicodeDecodeError #6387

Closed
benjamindeleener opened this issue May 8, 2016 · 5 comments
Closed

import matplotlib causes UnicodeDecodeError #6387

benjamindeleener opened this issue May 8, 2016 · 5 comments

Comments

@benjamindeleener
Copy link

benjamindeleener commented May 8, 2016

OS: Debian (neurodebian virtual machine: http://neuro.debian.net/vm.html)
Matplotlib version: 1.5.1, installed with miniconda on python 2.7.11

I created a python environment with matplotlib installed (and a bunch of other stuff). Unfortunately, when trying to import matplotlib, I get the following error:

(/home/brain/sct_3.0_beta8/python)brain@neurodebian:~$ python
Python 2.7.11 |Continuum Analytics, Inc.| (default, Dec  6 2015, 18:08:32) 
[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
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
UnicodeDecodeError: 'utf8' codec can't decode byte 0xb1 in position 35: invalid start byte

Any idea where this issue come from and how to fix it?
Thanks!

Original issue: spinalcordtoolbox/spinalcordtoolbox#862

@tacaswell
Copy link
Member

Do you have non-ascii characters in your user path?

Does this happen with python3?

@tacaswell
Copy link
Member

For reference

In [18]: chr(0xb1)
Out[18]: '±'

What is in your .matlplotlibrc file?

@benjamindeleener
Copy link
Author

I didn't try on Python 3 (I'll try soon) and I don't think I have non-ascii characters in my user path.
When I type chr(0xb1), I get the following result:

>>> chr(0xb1)
'\xb1'

And actually, it does not look that I have a .matplotlibrc file... (I looked in .config/matplotlib/)

And it seems matplotlib was not correctly installed. I uninstalled it and reinstalled it and now it works.
That's weird.

@tacaswell
Copy link
Member

tacaswell commented May 8, 2016

The output of chr is a python 2/3 difference. It looks like 3 correctly handles high-code points where as 2 falls back to str(int()) just displaying the hex for the byte value

@efiring
Copy link
Member

efiring commented Jul 15, 2016

I gather the problem has been solved. If not, feel free to reopen this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants