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

Latex not work because dvipng_hack_alpha does not work with dvipng that prints non ascii characters #4545

Closed
KalaShayminS opened this issue Jun 21, 2015 · 4 comments
Assignees

Comments

@KalaShayminS
Copy link

The matplotlib on my machines cannot work with LaTeX because of

  File "/export/opt/python/2.7.8/lib/python2.7/site-packages/matplotlib-1.4.2-py2.7-linux-x86_64.egg/matplotlib/texmanager.py", line 78, in dvipng_hack_alpha
    lines = stdout.decode('ascii').split('\n')
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc5 in position 43: ordinal not in range(128)

The code clip:

def dvipng_hack_alpha():
    try:
        p = Popen(['dvipng', '-version'], stdin=PIPE, stdout=PIPE,
                  stderr=STDOUT, close_fds=(sys.platform != 'win32'))
        stdout, stderr = p.communicate()
    except OSError:
        mpl.verbose.report('No dvipng was found', 'helpful')
        return False
    lines = stdout.decode('ascii').split('\n')

I think decode('ascii') code does not support non-ascii characters , while dvipng indeed prints one (the Author name) in some versions:

This is dvipng 1.5 Copyright 2002-2005 Jan-īe Larsson
dvipng 1.5
kpathsea version 3.5.4
Copyright (C) 2002-2005 Jan-īe Larsson.
There is NO warranty.  You may redistribute this software
under the terms of the GNU General Public License.
For more information about these matters, see the files
named COPYING and dvipng.c.
@tacaswell
Copy link
Member

Something funny is going on with your version of dvipng.

According to http://www.nongnu.org/dvipng/ the author is 'Jan-Åke Larsson' and on my machine I get

13:01 $ dvipng --version
This is dvipng (dvipng (TeX Live)) 1.14 Copyright 2002-2010 Jan-Ake Larsson
dvipng (dvipng (TeX Live)) 1.14
kpathsea version 6.2.0
Compiled with Freetype 2.5.5
Using libft 2.5.5
Copyright (C) 2002-2010 Jan-Ake Larsson.
There is NO warranty.  You may redistribute this software
under the terms of the GNU Lesser General Public License
version 3, see the COPYING file in the dvipng distribution
or <http://www.gnu.org/licenses/>.

neither of which match 'Jan-īe' as you report.

I see two solutions to this:

  • add ignore='replace' no the decode call
  • sort out the system encoding and use that.

The second is probably a better option, but the first is easier.

@tacaswell
Copy link
Member

see #4547 which should fix this.

@jenshnielsen
Copy link
Member

His name is really Jan-Åke Larsson http://people.isy.liu.se/jalar/

I guess he changed the output at some point in the last 10 years to avoid non ascii characters. I guess this should really be the ISO 8859-1/9/10/13/14/15 representation of Å see https://en.wikipedia.org/wiki/%C3%85

In any case your version of dvipng is quite old (2005 V 1.5) The version in texlive 2015 is 1.15. Is this part of an operation system distribution of latex? Since this is mainly aimed at old versions of dvipng I was thinking that it might be about time to deprecate the dvipng_hack_alpha function but if it's still useful that is obviously to early!

The output that I see from TeXLive 2015 is

This is dvipng (dvipng (TeX Live)) 1.15 Copyright 2002-2015 Jan-Ake Larsson
dvipng (dvipng (TeX Live)) 1.15
kpathsea version 6.2.1
Compiled with Freetype 2.5.5
Using libft 2.5.5
Copyright (C) 2002-2015 Jan-Ake Larsson.
There is NO warranty.  You may redistribute this software
under the terms of the GNU Lesser General Public License
version 3, see the COPYING file in the dvipng distribution
or <http://www.gnu.org/licenses/>.

@KalaShayminS
Copy link
Author

Hi, I am working on a CentOS 5 server, which is indeed ~10 years old. I have just complied dvipng 1.15 and it does not give non ascii characteres anymore, as you stated.

The "īe" comes from my terminal encoding which combines two characters into one that seems to be wrong. That is a display issue.

Thanks for the correction!

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