matplotlibtk-toolkitpythonanywherempld3

TclError when creating plots using mpld3 in pythonanywhere


I am creating plots using matplotlib and mpld3 (both successfully installed) but when plotting I got this error message:

...File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1767, in init#012 self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)#012TclError: no display name and no $DISPLAY environment variable.

Any idea how to solve that? thanks for your help


Solution

  • Try this

    import matplotlib
    matplotlib.use('Agg')
    

    Check this page for more informations