0 votes

Hello,

In a python notebook, I have succeeded in importing and using the seaborn library (based on matplotlib).

However, in a Rmarkdown report, I have the following error ImportError: No module named Tkinter.

How to use seaborn in a Rmarkdown report?

Sam

asked by

1 Answer

0 votes

Hello Sam,

The seaborn python library is indeed using matplotlib. This library contains multiple backends that are not necessarily installed or configured. When loading seaborn, it will try to load the default backend based on TCL/TK (UI framework) which is bundled in the Tkinter python package.

You need to use matplotlib.use("Agg") (or any other properly configured backend) before importing seaborn in order to force matplotlib to use the correct backend. For information, the Agg backend only computes the plots without displaying them.

In notebooks, the magic first line %pylab inline will trigger this method in order to use a backend that sends the output as HTML to the notebook.

Sam

answered by
992 questions
1,025 answers
1,077 comments
3,154 users

┬ęDataiku 2012-2018 - Privacy Policy