From c7e98aa744a7079b57d0bdc085c2526b764afcb0 Mon Sep 17 00:00:00 2001 From: tomoemon Date: Fri, 27 Nov 2015 15:37:40 +0900 Subject: [PATCH] use base64.encodestring on python2.7 --- lib/matplotlib/animation.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/matplotlib/animation.py b/lib/matplotlib/animation.py index 6a62384d1c54..0e9c106498b9 100644 --- a/lib/matplotlib/animation.py +++ b/lib/matplotlib/animation.py @@ -27,7 +27,12 @@ import platform import sys import itertools -import base64 +try: + # python3 + from base64 import encodebytes +except ImportError: + # python2 + from base64 import encodestring as encodebytes import contextlib import tempfile from matplotlib.cbook import iterable, is_string_like @@ -928,7 +933,7 @@ def to_html5_video(self): # Now open and base64 encode with open(f.name, 'rb') as video: - vid64 = base64.encodebytes(video.read()) + vid64 = encodebytes(video.read()) self._base64_video = vid64.decode('ascii') self._video_size = 'width="{0}" height="{1}"'.format( *writer.frame_size)