Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


ERROR: matplotlib.tests.test_backend_pgf.test_pdflatex on Python 3.x #1118

mdboom opened this Issue · 3 comments

2 participants


I'm getting this on Python 3.x only.

ERROR: matplotlib.tests.test_backend_pgf.test_pdflatex
Traceback (most recent call last):
  File "/home/mdboom/python3/lib/python3.2/site-packages/nose/", line 198, in runTest
  File "/home/mdboom/python3/lib/python3.2/site-packages/matplotlib/testing/", line 39, in failer
    result = f(*args, **kwargs)
  File "/home/mdboom/python3/lib/python3.2/site-packages/matplotlib/tests/", line 30, in backend_switcher
    result = func(*args, **kwargs)
  File "/home/mdboom/python3/lib/python3.2/site-packages/matplotlib/tests/", line 82, in test_pdflatex
  File "/home/mdboom/python3/lib/python3.2/site-packages/matplotlib/tests/", line 40, in compare_figure
  File "/home/mdboom/python3/lib/python3.2/site-packages/matplotlib/", line 475, in savefig
    return fig.savefig(*args, **kwargs)
  File "/home/mdboom/python3/lib/python3.2/site-packages/matplotlib/", line 1229, in savefig
    self.canvas.print_figure(*args, **kwargs)
  File "/home/mdboom/python3/lib/python3.2/site-packages/matplotlib/", line 2089, in print_figure
  File "/home/mdboom/python3/lib/python3.2/site-packages/matplotlib/backends/", line 694, in print_pdf
  File "/home/mdboom/python3/lib/python3.2/site-packages/matplotlib/backends/", line 674, in print_pgf
    renderer = RendererPgf(self.figure, fh)
  File "/home/mdboom/python3/lib/python3.2/site-packages/matplotlib/backends/", line 358, in __init__
    self.latexManager = LatexManagerFactory.get_latex_manager()
  File "/home/mdboom/python3/lib/python3.2/site-packages/matplotlib/backends/", line 205, in get_latex_manager
    new_inst = LatexManager()
  File "/home/mdboom/python3/lib/python3.2/site-packages/matplotlib/backends/", line 243, in __init__
    stdout, stderr = latex.communicate(self.latex_header + latex_end)
  File "/usr/lib64/python3.2/", line 819, in communicate
    return self._communicate(input)
  File "/usr/lib64/python3.2/", line 1425, in _communicate
    stdout, stderr = self._communicate_with_poll(input)
  File "/usr/lib64/python3.2/", line 1492, in _communicate_with_poll
    input_offset += os.write(fd, chunk)
TypeError: 'str' does not support the buffer interface
@pwuertz pwuertz was assigned

I have never worked with python3 before :/, but it looks like the py3 distinction between strings and bytes. Subprocess.communicate requires a byte buffer that must be explicitly encoded from a str.. (self.latex_header + latex_end).encode('utf-8')..

I'll try to setup a python 3 environment then ^^


Ok. Another problem. For me, in python3 this doesn't work anymore:

import codecs
import subprocess

proc = subprocess.Popen(["echo"], stdin=subprocess.PIPE,
proc_stdin = codecs.getwriter("utf8")(proc.stdin)

Apparently, the universal_newlines support is gone. It works if you omit this option. I don't know if this is a problem for windows or osx. For windows it's probably ok since I check for a latex prompt after newline.. and even with '\r\n' the newline is still the last character of a line. What about osx? Are they still using '\r' as a newline? I better find someone to test this :)


All right, I rewrote the part for the communication with the latex subprocess. Python3 seems to have trouble with subprocess+codecs+latex, so I'm using bytebuffers for reading the stdout now. Python2 tests pass, running a python3 example works, but I can't run the test suite with py3 yet (#745).

@pwuertz pwuertz closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.