Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c7e98aa

Browse files
committed
use base64.encodestring on python2.7
1 parent 6245d4e commit c7e98aa

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

lib/matplotlib/animation.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,12 @@
2727
import platform
2828
import sys
2929
import itertools
30-
import base64
30+
try:
31+
# python3
32+
from base64 import encodebytes
33+
except ImportError:
34+
# python2
35+
from base64 import encodestring as encodebytes
3136
import contextlib
3237
import tempfile
3338
from matplotlib.cbook import iterable, is_string_like
@@ -928,7 +933,7 @@ def to_html5_video(self):
928933

929934
# Now open and base64 encode
930935
with open(f.name, 'rb') as video:
931-
vid64 = base64.encodebytes(video.read())
936+
vid64 = encodebytes(video.read())
932937
self._base64_video = vid64.decode('ascii')
933938
self._video_size = 'width="{0}" height="{1}"'.format(
934939
*writer.frame_size)

0 commit comments

Comments
 (0)