Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

qrcode 8.0 requires more work for simplest use case #379

Open
williamjacksn opened this issue Oct 1, 2024 · 2 comments
Open

qrcode 8.0 requires more work for simplest use case #379

williamjacksn opened this issue Oct 1, 2024 · 2 comments

Comments

@williamjacksn
Copy link

This works with qrcode 7.4.2.

# pip install qrcode==7.4.2
Collecting qrcode==7.4.2
  Downloading qrcode-7.4.2-py3-none-any.whl.metadata (17 kB)
Collecting typing-extensions (from qrcode==7.4.2)
  Downloading typing_extensions-4.12.2-py3-none-any.whl.metadata (3.0 kB)
Collecting pypng (from qrcode==7.4.2)
  Downloading pypng-0.20220715.0-py3-none-any.whl.metadata (13 kB)
Downloading qrcode-7.4.2-py3-none-any.whl (46 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 46.2/46.2 kB 765.6 kB/s eta 0:00:00
Downloading pypng-0.20220715.0-py3-none-any.whl (58 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 58.1/58.1 kB 3.6 MB/s eta 0:00:00
Downloading typing_extensions-4.12.2-py3-none-any.whl (37 kB)
Installing collected packages: pypng, typing-extensions, qrcode
Successfully installed pypng-0.20220715.0 qrcode-7.4.2 typing-extensions-4.12.2

# qr test > test.png

# file test.png
test.png: PNG image data, 290 x 290, 1-bit grayscale, non-interlaced

But with qrcode 8.0, pypng is no longer automatically installed as a dependency.

# pip install qrcode==8.0
Collecting qrcode==8.0
  Downloading qrcode-8.0-py3-none-any.whl.metadata (17 kB)
Downloading qrcode-8.0-py3-none-any.whl (45 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 45.7/45.7 kB 864.8 kB/s eta 0:00:00
Installing collected packages: qrcode
Successfully installed qrcode-8.0

# qr test > test.png
Traceback (most recent call last):
  File "/usr/local/bin/qr", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/usr/local/lib/python3.12/site-packages/qrcode/console_scripts.py", line 137, in main
    img = qr.make_image(**kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/qrcode/main.py", line 363, in make_image
    from qrcode.image.pil import Image, PilImage
  File "/usr/local/lib/python3.12/site-packages/qrcode/image/pil.py", line 2, in <module>
    from PIL import Image, ImageDraw
ModuleNotFoundError: No module named 'PIL'

Even when pypng is installed, the qr command defaults to the pil factory.

# pip install qrcode[png]
Collecting qrcode[png]
  Downloading qrcode-8.0-py3-none-any.whl.metadata (17 kB)
Collecting pypng (from qrcode[png])
  Downloading pypng-0.20220715.0-py3-none-any.whl.metadata (13 kB)
Downloading pypng-0.20220715.0-py3-none-any.whl (58 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 58.1/58.1 kB 1.0 MB/s eta 0:00:00
Downloading qrcode-8.0-py3-none-any.whl (45 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 45.7/45.7 kB 2.1 MB/s eta 0:00:00
Installing collected packages: pypng, qrcode
Successfully installed pypng-0.20220715.0 qrcode-8.0

# qr test > test.png
Traceback (most recent call last):
  File "/usr/local/bin/qr", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/usr/local/lib/python3.12/site-packages/qrcode/console_scripts.py", line 137, in main
    img = qr.make_image(**kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/qrcode/main.py", line 363, in make_image
    from qrcode.image.pil import Image, PilImage
  File "/usr/local/lib/python3.12/site-packages/qrcode/image/pil.py", line 2, in <module>
    from PIL import Image, ImageDraw
ModuleNotFoundError: No module named 'PIL'

# qr --factory=png test > test.png

# file test.png
test.png: PNG image data, 290 x 290, 1-bit grayscale, non-interlaced
@maribedran
Copy link
Contributor

Thanks for noting this, @williamjacksn! We need to update the docs to make this clear. Since PNG is also an optional dependency, I think the fallback should be SVG, since it doesn't depend on any extra libraries.

@maribedran maribedran mentioned this issue Oct 3, 2024
@bartTC
Copy link
Member

bartTC commented Oct 3, 2024

Refs #338

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants