“TypeError: a bytes-like object is required, not 'str'” in savefig when using usetex:true












0















When using savefig with text.usetex:true in matplotlib, I get TypeError: a bytes-like object is required, not 'str'



EDIT: The solution for me was to upgrade matplotlib from 2.1.0 to 3.0.2



I can save to a png format with usetex:true but not pdf. I can save to pdf with usetex:false. Here is the minimal code required to produce the error:



import matplotlib as mpl
mpl.use('pdf')
import matplotlib.pyplot as plt

mpl.rcParams['text.usetex'] = True
fig, axes = plt.subplots(1, 1)
fig.savefig('test.pdf')


I have Miktex 2.9 installed, and also the most recent versions of dvipng and Ghostscript as mentionned here: https://matplotlib.org/tutorials/text/usetex.html?highlight=usetex



I added the following to my path:



C:Program Filesgsgs9.26bin
C:Program FilesMiKTeX 2.9miktexbinx64


I'm using Windows 10, Python 3.6.3 and matplotlib 2.1.0.



I also tried deleting my .matplotlib/tex.cache directory, with no success.



Full traceback:



File ".usetex.py", line 9, in <module>
fig.savefig('test.pdf')
File "C:UsersbobAppDataLocalProgramsPythonPython36-32libsite-packagesmatplotlibfigure.py", line 1814, in savefig
self.canvas.print_figure(fname, **kwargs)
File "C:UsersbobAppDataLocalProgramsPythonPython36-32libsite-packagesmatplotlibbackend_bases.py", line 2259, in print_figure
**kwargs)
File "C:UsersbobAppDataLocalProgramsPythonPython36-32libsite-packagesmatplotlibbackendsbackend_pdf.py", line 2592, in print_pdf
self.figure.draw(renderer)
File "C:UsersbobAppDataLocalProgramsPythonPython36-32libsite-packagesmatplotlibartist.py", line 55, in draw_wrapper
return draw(artist, renderer, *args, **kwargs)
File "C:UsersbobAppDataLocalProgramsPythonPython36-32libsite-packagesmatplotlibfigure.py", line 1295, in draw
renderer, self, artists, self.suppressComposite)
File "C:UsersbobAppDataLocalProgramsPythonPython36-32libsite-packagesmatplotlibimage.py", line 138, in _draw_list_compositing_images
a.draw(renderer)
File "C:UsersbobAppDataLocalProgramsPythonPython36-32libsite-packagesmatplotlibartist.py", line 55, in draw_wrapper
return draw(artist, renderer, *args, **kwargs)
File "C:UsersbobAppDataLocalProgramsPythonPython36-32libsite-packagesmatplotlibaxes_base.py", line 2399, in draw
mimage._draw_list_compositing_images(renderer, self, artists)
File "C:UsersbobAppDataLocalProgramsPythonPython36-32libsite-packagesmatplotlibimage.py", line 138, in _draw_list_compositing_images
a.draw(renderer)
File "C:UsersbobAppDataLocalProgramsPythonPython36-32libsite-packagesmatplotlibartist.py", line 55, in draw_wrapper
return draw(artist, renderer, *args, **kwargs)
File "C:UsersbobAppDataLocalProgramsPythonPython36-32libsite-packagesmatplotlibaxis.py", line 1138, in draw
tick.draw(renderer)
File "C:UsersbobAppDataLocalProgramsPythonPython36-32libsite-packagesmatplotlibartist.py", line 55, in draw_wrapper
return draw(artist, renderer, *args, **kwargs)
File "C:UsersbobAppDataLocalProgramsPythonPython36-32libsite-packagesmatplotlibaxis.py", line 282, in draw
self.label1.draw(renderer)
File "C:UsersbobAppDataLocalProgramsPythonPython36-32libsite-packagesmatplotlibartist.py", line 55, in draw_wrapper
return draw(artist, renderer, *args, **kwargs)
File "C:UsersbobAppDataLocalProgramsPythonPython36-32libsite-packagesmatplotlibtext.py", line 799, in draw
mtext=mtext)
File "C:UsersbobAppDataLocalProgramsPythonPython36-32libsite-packagesmatplotlibbackendsbackend_pdf.py", line 1944, in draw_tex
pdfname = self.file.dviFontName(dvifont)
File "C:UsersbobAppDataLocalProgramsPythonPython36-32libsite-packagesmatplotlibbackendsbackend_pdf.py", line 688, in dviFontName
psfont = self.texFontMap[dvifont.texname]
File "C:UsersbobAppDataLocalProgramsPythonPython36-32libsite-packagesmatplotlibdviread.py", line 866, in __getitem__
fn = find_tex_file(fn)
File "C:UsersbobAppDataLocalProgramsPythonPython36-32libsite-packagesmatplotlibdviread.py", line 1045, in find_tex_file
stderr=subprocess.PIPE)
File "C:UsersbobAppDataLocalProgramsPythonPython36-32libsubprocess.py", line 709, in __init__
restore_signals, start_new_session)
File "C:UsersbobAppDataLocalProgramsPythonPython36-32libsubprocess.py", line 971, in _execute_child
args = list2cmdline(args)
File "C:UsersbobAppDataLocalProgramsPythonPython36-32libsubprocess.py", line 461, in list2cmdline
needquote = (" " in arg) or ("t" in arg) or not arg
TypeError: a bytes-like object is required, not 'str'









share|improve this question

























  • Did you try to use savefig(b'test.pdf')?

    – Bakuriu
    Nov 28 '18 at 18:58











  • I tested the code with matplotlib 2.0.2, 2.2.2, 3.0.1 with python 3.6 on windows and miktex 2.9 and it works fine. I do not currently have any 2.1.0 environment for testing though, but maybe it's still a problem that can be resolved by updating matplotlib.

    – ImportanceOfBeingErnest
    Nov 28 '18 at 19:02











  • @ImportanceOfBeingErnest I upgraded to 3.0.2 and it works, thank you.

    – Laurent
    Nov 28 '18 at 19:09













  • @Bakuriu I tried, but it didn't work.

    – Laurent
    Nov 28 '18 at 19:09











  • Probably rather answer your own question, instead of writing the answer in the question, after all, a question is still a question, right? :-)

    – ImportanceOfBeingErnest
    Nov 28 '18 at 19:12
















0















When using savefig with text.usetex:true in matplotlib, I get TypeError: a bytes-like object is required, not 'str'



EDIT: The solution for me was to upgrade matplotlib from 2.1.0 to 3.0.2



I can save to a png format with usetex:true but not pdf. I can save to pdf with usetex:false. Here is the minimal code required to produce the error:



import matplotlib as mpl
mpl.use('pdf')
import matplotlib.pyplot as plt

mpl.rcParams['text.usetex'] = True
fig, axes = plt.subplots(1, 1)
fig.savefig('test.pdf')


I have Miktex 2.9 installed, and also the most recent versions of dvipng and Ghostscript as mentionned here: https://matplotlib.org/tutorials/text/usetex.html?highlight=usetex



I added the following to my path:



C:Program Filesgsgs9.26bin
C:Program FilesMiKTeX 2.9miktexbinx64


I'm using Windows 10, Python 3.6.3 and matplotlib 2.1.0.



I also tried deleting my .matplotlib/tex.cache directory, with no success.



Full traceback:



File ".usetex.py", line 9, in <module>
fig.savefig('test.pdf')
File "C:UsersbobAppDataLocalProgramsPythonPython36-32libsite-packagesmatplotlibfigure.py", line 1814, in savefig
self.canvas.print_figure(fname, **kwargs)
File "C:UsersbobAppDataLocalProgramsPythonPython36-32libsite-packagesmatplotlibbackend_bases.py", line 2259, in print_figure
**kwargs)
File "C:UsersbobAppDataLocalProgramsPythonPython36-32libsite-packagesmatplotlibbackendsbackend_pdf.py", line 2592, in print_pdf
self.figure.draw(renderer)
File "C:UsersbobAppDataLocalProgramsPythonPython36-32libsite-packagesmatplotlibartist.py", line 55, in draw_wrapper
return draw(artist, renderer, *args, **kwargs)
File "C:UsersbobAppDataLocalProgramsPythonPython36-32libsite-packagesmatplotlibfigure.py", line 1295, in draw
renderer, self, artists, self.suppressComposite)
File "C:UsersbobAppDataLocalProgramsPythonPython36-32libsite-packagesmatplotlibimage.py", line 138, in _draw_list_compositing_images
a.draw(renderer)
File "C:UsersbobAppDataLocalProgramsPythonPython36-32libsite-packagesmatplotlibartist.py", line 55, in draw_wrapper
return draw(artist, renderer, *args, **kwargs)
File "C:UsersbobAppDataLocalProgramsPythonPython36-32libsite-packagesmatplotlibaxes_base.py", line 2399, in draw
mimage._draw_list_compositing_images(renderer, self, artists)
File "C:UsersbobAppDataLocalProgramsPythonPython36-32libsite-packagesmatplotlibimage.py", line 138, in _draw_list_compositing_images
a.draw(renderer)
File "C:UsersbobAppDataLocalProgramsPythonPython36-32libsite-packagesmatplotlibartist.py", line 55, in draw_wrapper
return draw(artist, renderer, *args, **kwargs)
File "C:UsersbobAppDataLocalProgramsPythonPython36-32libsite-packagesmatplotlibaxis.py", line 1138, in draw
tick.draw(renderer)
File "C:UsersbobAppDataLocalProgramsPythonPython36-32libsite-packagesmatplotlibartist.py", line 55, in draw_wrapper
return draw(artist, renderer, *args, **kwargs)
File "C:UsersbobAppDataLocalProgramsPythonPython36-32libsite-packagesmatplotlibaxis.py", line 282, in draw
self.label1.draw(renderer)
File "C:UsersbobAppDataLocalProgramsPythonPython36-32libsite-packagesmatplotlibartist.py", line 55, in draw_wrapper
return draw(artist, renderer, *args, **kwargs)
File "C:UsersbobAppDataLocalProgramsPythonPython36-32libsite-packagesmatplotlibtext.py", line 799, in draw
mtext=mtext)
File "C:UsersbobAppDataLocalProgramsPythonPython36-32libsite-packagesmatplotlibbackendsbackend_pdf.py", line 1944, in draw_tex
pdfname = self.file.dviFontName(dvifont)
File "C:UsersbobAppDataLocalProgramsPythonPython36-32libsite-packagesmatplotlibbackendsbackend_pdf.py", line 688, in dviFontName
psfont = self.texFontMap[dvifont.texname]
File "C:UsersbobAppDataLocalProgramsPythonPython36-32libsite-packagesmatplotlibdviread.py", line 866, in __getitem__
fn = find_tex_file(fn)
File "C:UsersbobAppDataLocalProgramsPythonPython36-32libsite-packagesmatplotlibdviread.py", line 1045, in find_tex_file
stderr=subprocess.PIPE)
File "C:UsersbobAppDataLocalProgramsPythonPython36-32libsubprocess.py", line 709, in __init__
restore_signals, start_new_session)
File "C:UsersbobAppDataLocalProgramsPythonPython36-32libsubprocess.py", line 971, in _execute_child
args = list2cmdline(args)
File "C:UsersbobAppDataLocalProgramsPythonPython36-32libsubprocess.py", line 461, in list2cmdline
needquote = (" " in arg) or ("t" in arg) or not arg
TypeError: a bytes-like object is required, not 'str'









share|improve this question

























  • Did you try to use savefig(b'test.pdf')?

    – Bakuriu
    Nov 28 '18 at 18:58











  • I tested the code with matplotlib 2.0.2, 2.2.2, 3.0.1 with python 3.6 on windows and miktex 2.9 and it works fine. I do not currently have any 2.1.0 environment for testing though, but maybe it's still a problem that can be resolved by updating matplotlib.

    – ImportanceOfBeingErnest
    Nov 28 '18 at 19:02











  • @ImportanceOfBeingErnest I upgraded to 3.0.2 and it works, thank you.

    – Laurent
    Nov 28 '18 at 19:09













  • @Bakuriu I tried, but it didn't work.

    – Laurent
    Nov 28 '18 at 19:09











  • Probably rather answer your own question, instead of writing the answer in the question, after all, a question is still a question, right? :-)

    – ImportanceOfBeingErnest
    Nov 28 '18 at 19:12














0












0








0








When using savefig with text.usetex:true in matplotlib, I get TypeError: a bytes-like object is required, not 'str'



EDIT: The solution for me was to upgrade matplotlib from 2.1.0 to 3.0.2



I can save to a png format with usetex:true but not pdf. I can save to pdf with usetex:false. Here is the minimal code required to produce the error:



import matplotlib as mpl
mpl.use('pdf')
import matplotlib.pyplot as plt

mpl.rcParams['text.usetex'] = True
fig, axes = plt.subplots(1, 1)
fig.savefig('test.pdf')


I have Miktex 2.9 installed, and also the most recent versions of dvipng and Ghostscript as mentionned here: https://matplotlib.org/tutorials/text/usetex.html?highlight=usetex



I added the following to my path:



C:Program Filesgsgs9.26bin
C:Program FilesMiKTeX 2.9miktexbinx64


I'm using Windows 10, Python 3.6.3 and matplotlib 2.1.0.



I also tried deleting my .matplotlib/tex.cache directory, with no success.



Full traceback:



File ".usetex.py", line 9, in <module>
fig.savefig('test.pdf')
File "C:UsersbobAppDataLocalProgramsPythonPython36-32libsite-packagesmatplotlibfigure.py", line 1814, in savefig
self.canvas.print_figure(fname, **kwargs)
File "C:UsersbobAppDataLocalProgramsPythonPython36-32libsite-packagesmatplotlibbackend_bases.py", line 2259, in print_figure
**kwargs)
File "C:UsersbobAppDataLocalProgramsPythonPython36-32libsite-packagesmatplotlibbackendsbackend_pdf.py", line 2592, in print_pdf
self.figure.draw(renderer)
File "C:UsersbobAppDataLocalProgramsPythonPython36-32libsite-packagesmatplotlibartist.py", line 55, in draw_wrapper
return draw(artist, renderer, *args, **kwargs)
File "C:UsersbobAppDataLocalProgramsPythonPython36-32libsite-packagesmatplotlibfigure.py", line 1295, in draw
renderer, self, artists, self.suppressComposite)
File "C:UsersbobAppDataLocalProgramsPythonPython36-32libsite-packagesmatplotlibimage.py", line 138, in _draw_list_compositing_images
a.draw(renderer)
File "C:UsersbobAppDataLocalProgramsPythonPython36-32libsite-packagesmatplotlibartist.py", line 55, in draw_wrapper
return draw(artist, renderer, *args, **kwargs)
File "C:UsersbobAppDataLocalProgramsPythonPython36-32libsite-packagesmatplotlibaxes_base.py", line 2399, in draw
mimage._draw_list_compositing_images(renderer, self, artists)
File "C:UsersbobAppDataLocalProgramsPythonPython36-32libsite-packagesmatplotlibimage.py", line 138, in _draw_list_compositing_images
a.draw(renderer)
File "C:UsersbobAppDataLocalProgramsPythonPython36-32libsite-packagesmatplotlibartist.py", line 55, in draw_wrapper
return draw(artist, renderer, *args, **kwargs)
File "C:UsersbobAppDataLocalProgramsPythonPython36-32libsite-packagesmatplotlibaxis.py", line 1138, in draw
tick.draw(renderer)
File "C:UsersbobAppDataLocalProgramsPythonPython36-32libsite-packagesmatplotlibartist.py", line 55, in draw_wrapper
return draw(artist, renderer, *args, **kwargs)
File "C:UsersbobAppDataLocalProgramsPythonPython36-32libsite-packagesmatplotlibaxis.py", line 282, in draw
self.label1.draw(renderer)
File "C:UsersbobAppDataLocalProgramsPythonPython36-32libsite-packagesmatplotlibartist.py", line 55, in draw_wrapper
return draw(artist, renderer, *args, **kwargs)
File "C:UsersbobAppDataLocalProgramsPythonPython36-32libsite-packagesmatplotlibtext.py", line 799, in draw
mtext=mtext)
File "C:UsersbobAppDataLocalProgramsPythonPython36-32libsite-packagesmatplotlibbackendsbackend_pdf.py", line 1944, in draw_tex
pdfname = self.file.dviFontName(dvifont)
File "C:UsersbobAppDataLocalProgramsPythonPython36-32libsite-packagesmatplotlibbackendsbackend_pdf.py", line 688, in dviFontName
psfont = self.texFontMap[dvifont.texname]
File "C:UsersbobAppDataLocalProgramsPythonPython36-32libsite-packagesmatplotlibdviread.py", line 866, in __getitem__
fn = find_tex_file(fn)
File "C:UsersbobAppDataLocalProgramsPythonPython36-32libsite-packagesmatplotlibdviread.py", line 1045, in find_tex_file
stderr=subprocess.PIPE)
File "C:UsersbobAppDataLocalProgramsPythonPython36-32libsubprocess.py", line 709, in __init__
restore_signals, start_new_session)
File "C:UsersbobAppDataLocalProgramsPythonPython36-32libsubprocess.py", line 971, in _execute_child
args = list2cmdline(args)
File "C:UsersbobAppDataLocalProgramsPythonPython36-32libsubprocess.py", line 461, in list2cmdline
needquote = (" " in arg) or ("t" in arg) or not arg
TypeError: a bytes-like object is required, not 'str'









share|improve this question
















When using savefig with text.usetex:true in matplotlib, I get TypeError: a bytes-like object is required, not 'str'



EDIT: The solution for me was to upgrade matplotlib from 2.1.0 to 3.0.2



I can save to a png format with usetex:true but not pdf. I can save to pdf with usetex:false. Here is the minimal code required to produce the error:



import matplotlib as mpl
mpl.use('pdf')
import matplotlib.pyplot as plt

mpl.rcParams['text.usetex'] = True
fig, axes = plt.subplots(1, 1)
fig.savefig('test.pdf')


I have Miktex 2.9 installed, and also the most recent versions of dvipng and Ghostscript as mentionned here: https://matplotlib.org/tutorials/text/usetex.html?highlight=usetex



I added the following to my path:



C:Program Filesgsgs9.26bin
C:Program FilesMiKTeX 2.9miktexbinx64


I'm using Windows 10, Python 3.6.3 and matplotlib 2.1.0.



I also tried deleting my .matplotlib/tex.cache directory, with no success.



Full traceback:



File ".usetex.py", line 9, in <module>
fig.savefig('test.pdf')
File "C:UsersbobAppDataLocalProgramsPythonPython36-32libsite-packagesmatplotlibfigure.py", line 1814, in savefig
self.canvas.print_figure(fname, **kwargs)
File "C:UsersbobAppDataLocalProgramsPythonPython36-32libsite-packagesmatplotlibbackend_bases.py", line 2259, in print_figure
**kwargs)
File "C:UsersbobAppDataLocalProgramsPythonPython36-32libsite-packagesmatplotlibbackendsbackend_pdf.py", line 2592, in print_pdf
self.figure.draw(renderer)
File "C:UsersbobAppDataLocalProgramsPythonPython36-32libsite-packagesmatplotlibartist.py", line 55, in draw_wrapper
return draw(artist, renderer, *args, **kwargs)
File "C:UsersbobAppDataLocalProgramsPythonPython36-32libsite-packagesmatplotlibfigure.py", line 1295, in draw
renderer, self, artists, self.suppressComposite)
File "C:UsersbobAppDataLocalProgramsPythonPython36-32libsite-packagesmatplotlibimage.py", line 138, in _draw_list_compositing_images
a.draw(renderer)
File "C:UsersbobAppDataLocalProgramsPythonPython36-32libsite-packagesmatplotlibartist.py", line 55, in draw_wrapper
return draw(artist, renderer, *args, **kwargs)
File "C:UsersbobAppDataLocalProgramsPythonPython36-32libsite-packagesmatplotlibaxes_base.py", line 2399, in draw
mimage._draw_list_compositing_images(renderer, self, artists)
File "C:UsersbobAppDataLocalProgramsPythonPython36-32libsite-packagesmatplotlibimage.py", line 138, in _draw_list_compositing_images
a.draw(renderer)
File "C:UsersbobAppDataLocalProgramsPythonPython36-32libsite-packagesmatplotlibartist.py", line 55, in draw_wrapper
return draw(artist, renderer, *args, **kwargs)
File "C:UsersbobAppDataLocalProgramsPythonPython36-32libsite-packagesmatplotlibaxis.py", line 1138, in draw
tick.draw(renderer)
File "C:UsersbobAppDataLocalProgramsPythonPython36-32libsite-packagesmatplotlibartist.py", line 55, in draw_wrapper
return draw(artist, renderer, *args, **kwargs)
File "C:UsersbobAppDataLocalProgramsPythonPython36-32libsite-packagesmatplotlibaxis.py", line 282, in draw
self.label1.draw(renderer)
File "C:UsersbobAppDataLocalProgramsPythonPython36-32libsite-packagesmatplotlibartist.py", line 55, in draw_wrapper
return draw(artist, renderer, *args, **kwargs)
File "C:UsersbobAppDataLocalProgramsPythonPython36-32libsite-packagesmatplotlibtext.py", line 799, in draw
mtext=mtext)
File "C:UsersbobAppDataLocalProgramsPythonPython36-32libsite-packagesmatplotlibbackendsbackend_pdf.py", line 1944, in draw_tex
pdfname = self.file.dviFontName(dvifont)
File "C:UsersbobAppDataLocalProgramsPythonPython36-32libsite-packagesmatplotlibbackendsbackend_pdf.py", line 688, in dviFontName
psfont = self.texFontMap[dvifont.texname]
File "C:UsersbobAppDataLocalProgramsPythonPython36-32libsite-packagesmatplotlibdviread.py", line 866, in __getitem__
fn = find_tex_file(fn)
File "C:UsersbobAppDataLocalProgramsPythonPython36-32libsite-packagesmatplotlibdviread.py", line 1045, in find_tex_file
stderr=subprocess.PIPE)
File "C:UsersbobAppDataLocalProgramsPythonPython36-32libsubprocess.py", line 709, in __init__
restore_signals, start_new_session)
File "C:UsersbobAppDataLocalProgramsPythonPython36-32libsubprocess.py", line 971, in _execute_child
args = list2cmdline(args)
File "C:UsersbobAppDataLocalProgramsPythonPython36-32libsubprocess.py", line 461, in list2cmdline
needquote = (" " in arg) or ("t" in arg) or not arg
TypeError: a bytes-like object is required, not 'str'






python matplotlib






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 28 '18 at 19:10







Laurent

















asked Nov 28 '18 at 18:55









LaurentLaurent

235




235













  • Did you try to use savefig(b'test.pdf')?

    – Bakuriu
    Nov 28 '18 at 18:58











  • I tested the code with matplotlib 2.0.2, 2.2.2, 3.0.1 with python 3.6 on windows and miktex 2.9 and it works fine. I do not currently have any 2.1.0 environment for testing though, but maybe it's still a problem that can be resolved by updating matplotlib.

    – ImportanceOfBeingErnest
    Nov 28 '18 at 19:02











  • @ImportanceOfBeingErnest I upgraded to 3.0.2 and it works, thank you.

    – Laurent
    Nov 28 '18 at 19:09













  • @Bakuriu I tried, but it didn't work.

    – Laurent
    Nov 28 '18 at 19:09











  • Probably rather answer your own question, instead of writing the answer in the question, after all, a question is still a question, right? :-)

    – ImportanceOfBeingErnest
    Nov 28 '18 at 19:12



















  • Did you try to use savefig(b'test.pdf')?

    – Bakuriu
    Nov 28 '18 at 18:58











  • I tested the code with matplotlib 2.0.2, 2.2.2, 3.0.1 with python 3.6 on windows and miktex 2.9 and it works fine. I do not currently have any 2.1.0 environment for testing though, but maybe it's still a problem that can be resolved by updating matplotlib.

    – ImportanceOfBeingErnest
    Nov 28 '18 at 19:02











  • @ImportanceOfBeingErnest I upgraded to 3.0.2 and it works, thank you.

    – Laurent
    Nov 28 '18 at 19:09













  • @Bakuriu I tried, but it didn't work.

    – Laurent
    Nov 28 '18 at 19:09











  • Probably rather answer your own question, instead of writing the answer in the question, after all, a question is still a question, right? :-)

    – ImportanceOfBeingErnest
    Nov 28 '18 at 19:12

















Did you try to use savefig(b'test.pdf')?

– Bakuriu
Nov 28 '18 at 18:58





Did you try to use savefig(b'test.pdf')?

– Bakuriu
Nov 28 '18 at 18:58













I tested the code with matplotlib 2.0.2, 2.2.2, 3.0.1 with python 3.6 on windows and miktex 2.9 and it works fine. I do not currently have any 2.1.0 environment for testing though, but maybe it's still a problem that can be resolved by updating matplotlib.

– ImportanceOfBeingErnest
Nov 28 '18 at 19:02





I tested the code with matplotlib 2.0.2, 2.2.2, 3.0.1 with python 3.6 on windows and miktex 2.9 and it works fine. I do not currently have any 2.1.0 environment for testing though, but maybe it's still a problem that can be resolved by updating matplotlib.

– ImportanceOfBeingErnest
Nov 28 '18 at 19:02













@ImportanceOfBeingErnest I upgraded to 3.0.2 and it works, thank you.

– Laurent
Nov 28 '18 at 19:09







@ImportanceOfBeingErnest I upgraded to 3.0.2 and it works, thank you.

– Laurent
Nov 28 '18 at 19:09















@Bakuriu I tried, but it didn't work.

– Laurent
Nov 28 '18 at 19:09





@Bakuriu I tried, but it didn't work.

– Laurent
Nov 28 '18 at 19:09













Probably rather answer your own question, instead of writing the answer in the question, after all, a question is still a question, right? :-)

– ImportanceOfBeingErnest
Nov 28 '18 at 19:12





Probably rather answer your own question, instead of writing the answer in the question, after all, a question is still a question, right? :-)

– ImportanceOfBeingErnest
Nov 28 '18 at 19:12












1 Answer
1






active

oldest

votes


















0














Thanks to @ImportanceOfBeingErnest, I upgraded matplotlib from 2.1.0 to 3.0.2 and the error doesn't show up anymore.






share|improve this answer
























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53526266%2ftypeerror-a-bytes-like-object-is-required-not-str-in-savefig-when-using-us%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    Thanks to @ImportanceOfBeingErnest, I upgraded matplotlib from 2.1.0 to 3.0.2 and the error doesn't show up anymore.






    share|improve this answer




























      0














      Thanks to @ImportanceOfBeingErnest, I upgraded matplotlib from 2.1.0 to 3.0.2 and the error doesn't show up anymore.






      share|improve this answer


























        0












        0








        0







        Thanks to @ImportanceOfBeingErnest, I upgraded matplotlib from 2.1.0 to 3.0.2 and the error doesn't show up anymore.






        share|improve this answer













        Thanks to @ImportanceOfBeingErnest, I upgraded matplotlib from 2.1.0 to 3.0.2 and the error doesn't show up anymore.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 29 '18 at 20:07









        LaurentLaurent

        235




        235
































            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53526266%2ftypeerror-a-bytes-like-object-is-required-not-str-in-savefig-when-using-us%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Contact image not getting when fetch all contact list from iPhone by CNContact

            count number of partitions of a set with n elements into k subsets

            A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks