0

When I use qrcode module like this:

import qrcode

hello = qrcode.make("hello")

type(hello)
hello.save("test.png")

I get these errors and can't solve them:

Traceback (most recent call last):
  File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/qrcode/image/pil.py", line 5, in <module>
    from PIL import Image, ImageDraw
ModuleNotFoundError: No module named 'PIL'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/data/data/com.termux/files/home/./py", line 5, in <module>
    hello = qrcode.make("hello")
  File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/qrcode/main.py", line 13, in make
    return qr.make_image()
  File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/qrcode/main.py", line 296, in make_image
    from qrcode.image.pil import PilImage
  File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/qrcode/image/pil.py", line 7, in <module>
    import Image
ModuleNotFoundError: No module named 'Image'

I'm using python 3.10

Avinash
  • 875
  • 6
  • 20

1 Answers1

0

You can (re)install QR Code generator Python package that includes the Pillow package for generating images using:

pip install qrcode[pil]

To install the Pillow package individually that include the Image class:

pip install Pillow