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

Skip to content

Commit 2baedb0

Browse files
committed
Merge pull request #5570 from tomoemon/fix_base64_animation
use base64.encodestring on python2.7
1 parent a385d33 commit 2baedb0

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
@@ -927,7 +932,7 @@ def to_html5_video(self):
927932

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

0 commit comments

Comments
 (0)