Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python - QRCode error "No module named 'image'"

Tags:

python

qr-code

I am trying to create an QRCode by using the 'qrcode' library. However, when I try to make an image, I get the following error:

Traceback (most recent call last):
  File "C:\Program Files (x86)\Python 3.5\lib\site-packages\qrcode\image\pil.py", line 6, in <module>
    from PIL import Image, ImageDraw
ImportError: No module named 'PIL'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:/Users/Floris/Documents/GitHub/MiniProject-GroepV1L/TEST_QR.py", line 4, in <module>
    img = qrcode.make(string)
  File "C:\Program Files (x86)\Python 3.5\lib\site-packages\qrcode\main.py", line 11, in make
    return qr.make_image()
  File "C:\Program Files (x86)\Python 3.5\lib\site-packages\qrcode\main.py", line 256, in make_image
    from qrcode.image.pil import PilImage
  File "C:\Program Files (x86)\Python 3.5\lib\site-packages\qrcode\image\pil.py", line 8, in <module>
    import Image
ImportError: No module named 'Image'

The code I have right now is:

import qrcode

string = "This is a test string for StackOverflow"
img = qrcode.make(string)
like image 371
Thidal Avatar asked Sep 29 '26 09:09

Thidal


1 Answers

You have to install Pillow:

pip install pillow

And probably some other dependencies.

You should have installed the qrcode package using pip so that the dependencies would have been installed.

like image 192
Lucas Infante Avatar answered Sep 30 '26 23:09

Lucas Infante