Running python recipe/building dataset in the flow %pylab inline doesn't work due to invalid syntax

Solved!
dominic_bardele
Level 2
Running python recipe/building dataset in the flow %pylab inline doesn't work due to invalid syntax
Hi, I have to use a workaround of writing a file in my python code to get output from a lab recipe. I'm getting a syntax error at the "%pylab inline" code line (I think because of the "%" sign). I tried using the 2 commented lines below in place of it but then I get a Tkinter error. Any suggestions?

Thanks,

Dom



%pylab inline
#import matplotlib ... tried to use this and the line below to get past the error in the recipe but got the Tkinter error
#import matplotlib.pyplot as plt
0 Kudos
1 Solution
Clรฉment_Stenac
Hi,

"%pylab inline" is a notebook-only construct which cannot work in a recipe

For the Tkinter error, you need to tell matplotlib that you want it to work in memory (instead of displaying the image) by doing this, before importing pyplot:

import matplotlib
matplotlib.use("Agg")

View solution in original post

2 Replies
Clรฉment_Stenac
Hi,

"%pylab inline" is a notebook-only construct which cannot work in a recipe

For the Tkinter error, you need to tell matplotlib that you want it to work in memory (instead of displaying the image) by doing this, before importing pyplot:

import matplotlib
matplotlib.use("Agg")
dominic_bardele
Level 2
Author
BAM! Thank you...that solved it!
0 Kudos

Labels

?
Labels (2)
A banner prompting to get Dataiku