Python - QRCode 错误 "No module named ' 图像'"

标签 python qr-code

我正在尝试使用“qrcode”库创建一个 QRCode。
但是,当我尝试制作图像时,出现以下错误:

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'

我现在拥有的代码是:
import qrcode

string = "This is a test string for StackOverflow"
img = qrcode.make(string)

最佳答案

你必须安装枕头:

pip install pillow

可能还有其他一些依赖项。

您应该已经使用 pip 安装了 qrcode 包,以便安装依赖项。

关于Python - QRCode 错误 "No module named ' 图像'",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33123726/

相关文章:

python - sqlalchemy 缓存一些查询

ios - 在 xCode 中编码 QR 码/测试可能吗?

html - CSS:为 QR 相机设计一个空框

c# - 使用 UWP C# 的 Hololens 条码读取器

http - 带有 http POST 的二维码

java - 使用 zxing 解码 QRCode。 java

python - 是否有可能使用 Python 标准库(比如 2.5 版)执行参数化的 MS-SQL 查询?

python - 使用 dos2unix 将 windows 文件转换为 unix 的 shell 脚本

python - 如何使用 Python 2.7 通过多线程(异步下载)通过 HTTP 下载文件

python - 使用 Python 训练 arima 模型时如何解决 LinAlgError 和 ValueError