当我使用qrcode
模块时:
import qrcode
hello = qrcode.make("hello")
type(hello)
hello.save("test.png")
我得到这些错误,无法解决它们:
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'
我正在使用python 3.10
您可以(重新)安装包含Pillow
包的QR码生成器Python包,用于生成图像:
pip install qrcode[pil]
单独安装包含Image
类的Pillow
包:
pip install Pillow