0

I'm using the Jupyter notebook extension in VS Code. I'm using Camelot to extract tables from a pdf, and I'm trying to do some visual debugging to find the coordinates of the column separators.

When running:

camelot.plot(tables[1], kind='text').show()

I get the warning: "UserWarning: Matplotlib is currently using module://matplotlib_inline.backend_inline, which is a non-GUI backend, so cannot show the figure."

From https://pythonguides.com/matplotlib-is-currently-using-agg-a-non-gui-backend/ I understood the problem is I have no GUI backend. That website suggests using tkinter as the GUI backend. So I did pip install tk to install tkinter into my virtual environment. Then added import to my code: from tkinter import *.

After closing the project folder, exiting VS Code and restarting, when I run

camelot.plot(tables[1], kind='text').show()

I get the same warning: "UserWarning: Matplotlib is currently using module://matplotlib_inline.backend_inline, which is a non-GUI backend, so cannot show the figure."

How do I get a GUI backend set up the way matplotlib wants?

jub
  • 377
  • 1
  • 2
  • 14
  • Does this answer your question? [How can I open the interactive matplotlib window in IPython notebook?](https://stackoverflow.com/questions/14261903/how-can-i-open-the-interactive-matplotlib-window-in-ipython-notebook) – Ahmed AEK Oct 23 '22 at 22:46
  • @AhmedAEK thanks, that introduced me to the phrase "interactive matplotlib", and a search on that led me to the solution. – jub Nov 06 '22 at 15:14

1 Answers1

1

Seems there are various solutions, some of which are dated. A solution I found that works as of this post (2022) is

  1. install ipympl to the environment (since I already have jupyter notebook installed in my virtual env, all of the requirements for ipympl were already present, and the only package that needed to be installed was 'ipympl' itself.
  2. add the following code (after import statements): %matplotlib widget

That's it. Now I when I plot something, I get the usual static plot as well as an interactive plot that allows me to see x,y coordinates on the plot as I move the mouse around.

jub
  • 377
  • 1
  • 2
  • 14