Matplotlib Backened change during Training a DL Model

Matplotlib Backened change during Training a DL Model

If you are training something on remote server where you dont have root access and get an error like your python is not configured for tkinter. This is nothing but maybe somewhere in your pipe

Then you’re options are :

  • First install tkinter, note that since you do not have sudo priviledge, you have to install tcl8.6-dev and tk8.6-dev from source too.
  • Install Python from source again : Here is a great link describing the process
  • In the last step you have to explicitly pass where your tkinter files are located during the ./configure.

After this you should

be fine. But there is another way to bypass this stuff. I am assuming that you really isn’t using GUI and sticking to terminal, in that case you don’t need tkinter at all, why install it. As I said, it’s the matplotlib that’s the culprit here, so what you can do is change it’s backend from tkinter (TkAgg) to antigrain(Agg). Then we won’t need tkinter at all.

Here’s how to do that :

  • Find where is your matplotlib file is located :
>>> import matplotlib
>>> matplotlib.matplotlib_fname()
'/home/foo/.config/matplotlib/matplotlibrc'
  • If there is no file create one in ‘/home/foo/.config/matplotlib/matplotlibrc’

In that file just change this (or if created enter just this) : backend : Agg

Save it and run !

:tada: You should be rolling !!

References:

comments powered by Disqus