title: How to display an image from a numpy array in tkinter?
body: <p>The following short code is meant to create an array with numpy, convert it into an image object with PIL and then insert into a canvas on a tkinter window.</p>
  
  <pre><code>from tkinter import *
  from PIL import Image
  
  root = Tk()
  array = np.ones((40,40))*150
  img = Image.fromarray(array)
  canvas = Canvas(root,width=300,height=300)
  canvas.pack()
  canvas.create_image(20,20,anchor=NW,image=img)
  
  root.mainloop()
  </code></pre>
  
  <p>This throws the error:</p>
  
  <pre><code>TclError: image "&lt;PIL.Image.Image image mode=F size=40x40 at 0x7F42D3BC3290&gt;" doesn't exist
  </code></pre>