The PGF backend only works on python2.7 and + #1173

NelleV opened this Issue Aug 30, 2012 · 4 comments

4 participants


The pgf backend relies on a new feature of the subprocess module from python2.7: subprocess.check_output; This command is basically like runs, but returns the outputs as a bytestring.

I'll provide a patch for that.

Here's the traceback of the failing tests:

ERROR: main.test_rcupdate

Traceback (most recent call last):
File "/bioinfo/users/nvaroqua/Projects/matplotlib/env/lib/python2.6/site-packages/nose/", line 197, in runTest
File "tests/", line 45, in backend_switcher
result = func(
args, *kwargs)
File "tests/", line 131, in test_rcupdate
compare_figure('pgf_rcupdate%d.pdf' % (i+1))
File "tests/", line 56, in compare_figure
File "/bioinfo/users/nvaroqua/Projects/matplotlib/env/lib/python2.6/site-packages/matplotlib/", line 475, in savefig
return fig.savefig(
args, *kwargs)
File "/bioinfo/users/nvaroqua/Projects/matplotlib/env/lib/python2.6/site-packages/matplotlib/", line 1267, in savefig
args, *kwargs)
File "/bioinfo/users/nvaroqua/Projects/matplotlib/env/lib/python2.6/site-packages/matplotlib/", line 2091, in print_figure
File "/bioinfo/users/nvaroqua/Projects/matplotlib/env/lib/python2.6/site-packages/matplotlib/backends/", line 743, in print_pdf
File "/bioinfo/users/nvaroqua/Projects/matplotlib/env/lib/python2.6/site-packages/matplotlib/backends/", line 722, in _print_pdf_to_fh
subprocess.check_output(cmdargs, stderr=subprocess.STDOUT)
AttributeError: 'module' object has no attribute 'check_output'

Matplotlib Developers member

Does anyone actually use python2.6 anymore? [expecting a grilling now ;-) ].

Will be a simple one to fix at least. @NelleV: Are you willing to work on this?


@pelson yep, working on it right now. i've got several options to fix the problem:

  1. use `check_call (which has been introduced in python2.5), but that implies have the standard output printed, and it's very ugly
  2. reimplement check_output in some way, and use this implementation
  3. use the scikit-learn's trick of copy pasting part of the stdlib in a utils module, and redirect the import when python2.6 stops being supported by matplotlib.

I'm in favor of the last one, as it's not much work for me (copy pasting 10lines of code from the python2.7 stdlib) :)

(and I actually have server's running with python 2.3.4 and python 2.4 :) )


Uh, sorry about that.. I think I used check_output all over the place.

If this function is a problem for this release I would just stick to

proc = subprocess.Popen
check proc.returncode

but since NelleV seems to be working on this already let's see what he comes up with :)


@pwuertz it was only used in the pgf backend, so it was very quick to fix. I think other backend might benefit from this method too, so having a nice common method seems like a good idea!

@efiring efiring pushed a commit that closed this issue Sep 1, 2012
@NelleV NelleV closes #1173 - backporting python2.7 subprocess's check_output to be …
…able to support python 2.6
@efiring efiring closed this in 0a0ac8c Sep 1, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment