Ludwig: Import Error: Cannot load backend 'TkAgg' which requires the 'tk' interactive framework, as 'headless' is currently running

Created on 12 Feb 2019  路  10Comments  路  Source: ludwig-ai/ludwig

I'm facing import error while executing the ludwig from google colab.. !!

Below is the code which I executed in steps:

  1. Loading Ludwig
    !pip install ludwig

  2. Upload file from local to Drive - to use in Colab
    from google.colab import files
    uploaded = files.upload()

  3. Train DataSet using ludwig cmd
    !ludwig train --data_csv ludwig_traindataset_1.csv --model_definition_file model_def.yaml

My model_def.yaml

input_features:
  - name: utterance
    type: sequence
    encoder: rnn
    cell_type: lstm
    bidirectional: true
    num_layers: 2
    reduce_output: None

output_features:
  - name: intent
    type: category
    reduce_input: sum
    num_fc_layers: 1
    fc_size: 64
  - name: slots
    type: sequence
    decoder: tagger

Dummy Dataset:

image

Attached the screenshot error:

image

Can anyone help me on this in _Google Colab GPU / Python 3.6_

bug waiting for answer

Most helpful comment

Yes I will update to version 0.1.1 once enough bugs are fixed. In the mean time can you please try with pip install https://github.com/uber/ludwig/archive/master.zip which should install the current code in the master branch?

All 10 comments

Looking into it.

So it turns out mpl.use('TKAgg') was needed to render windows in Mac OS X in older versions of matplotlib. I removed it and increased the matplotlib version in the requirements.
Please confirm this solves the issue.

@w4nderlust pip is pulling only the old release version not newer one. :( because the error is still throwing which points to older code.

Yes I will update to version 0.1.1 once enough bugs are fixed. In the mean time can you please try with pip install https://github.com/uber/ludwig/archive/master.zip which should install the current code in the master branch?

@w4nderlust _TkAgg issue got fixed_ but am getting KeyError: utterance error.

image

image

That is likely a problem with your data. Lookin at the screenshot you posted, you are escaping commas that separate columns, you should not do that, you should only escape commas if you have them inside strings. Closing this as the original issue is solved, let me know if fixing the dataset doesn't solve the problem.

@w4nderlust worked like a charm 馃憤

Glad it worked!

What solved the problem for me was to restart my kernel, import the following first:

import matplotlib matplotlib.use('TKAgg')

Then,

import matplotlib.pyplot as plt

What solved the problem for me was to restart my kernel, import the following first:

import matplotlib
matplotlib.use('TKAgg')

Then,
import matplotlib.pyplot as plt

You probably imported matplotlib with another framework before you tried to change to TKAgg. Restart your kernel.

reference

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Aashish-1008 picture Aashish-1008  路  4Comments

loretoparisi picture loretoparisi  路  7Comments

catr1ne55 picture catr1ne55  路  4Comments

tommylees112 picture tommylees112  路  4Comments

wschroederga picture wschroederga  路  6Comments