title: Generate a PNG QRCode using Python
body: <p>I am trying to create a .png of a QRCode using Python. However, I am having difficulty. When I run this code:</p>
  
  <pre><code>import tkinter as tk
  from PIL import Image,ImageTk
  import pyqrcode
  from tkinter.font import Font
  import random
  
  def generateQR():
      num=random.randint(1,2)
      if num==1:
          QRCode=pyqrcode.create("You Win!")
          QRCode.png("QRCode.png",scale=8)
          print("done")
  
  generateQR()
  </code></pre>
  
  <p>The QRCode.png file is not readable; however, the .svg version is (using Internet Explorer).</p>
  
  <p>I have read <a href="https://pypi.org/project/PyQRCode/" rel="nofollow noreferrer">https://pypi.org/project/PyQRCode/</a> and have seen the use of the <code>pypng</code> module. However, I have tried this and the resultant .png was still unreadable.</p>