heuer / segno

Python QR Code and Micro QR Code encoder
https://pypi.org/project/segno/
BSD 3-Clause "New" or "Revised" License
624 stars 54 forks source link

AttributeError: <class 'segno.QRCode'> object has no attribute to_pil #110

Closed Siddharth1India closed 1 year ago

Siddharth1India commented 2 years ago

Title is the error I am getting.

heuer commented 2 years ago

Thanks for your msg.

You need to install the qrcode_artistic plugin, see https://segno.readthedocs.io/en/latest/artistic-qrcodes.html

If the plugin is available, the QRCode object gets magically the to_pil method.

amzar96 commented 1 year ago

Hi, I already install qrcode_artistic however still get the same error

image
heuer commented 1 year ago

Please provide more information. Do you have segno installed as well?

amzar96 commented 1 year ago

Hi @heuer ,

image

sego and qrcode-artistic installed.

heuer commented 1 year ago

Strange, it works for me. Can you provide the error message? Do you have Pillow installed as well?

(.venv) ~/projects/segno-test> pip install segno
Collecting segno
  Using cached segno-1.5.2-py2.py3-none-any.whl (83 kB)
Installing collected packages: segno
Successfully installed segno-1.5.2
(.venv) ~/projects/segno-test> pip install qrcode-artistic
Collecting qrcode-artistic
  Downloading qrcode_artistic-2.1.0-py2.py3-none-any.whl (6.8 kB)
Installing collected packages: qrcode-artistic
Successfully installed qrcode-artistic-2.1.0
(.venv) ~/projects/segno-test> pip install Pillow
Collecting Pillow
  Obtaining dependency information for Pillow from https://files.pythonhosted.org/packages/3c/49/f87cecbdec4b00cc1187f01196d48c08828204cd861915fab44972dc705c/Pillow-10.0.1-cp311-cp311-manylinux_2_28_x86_64.whl.metadata
  Downloading Pillow-10.0.1-cp311-cp311-manylinux_2_28_x86_64.whl.metadata (9.5 kB)
Downloading Pillow-10.0.1-cp311-cp311-manylinux_2_28_x86_64.whl (3.6 MB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 3.6/3.6 MB 7.2 MB/s eta 0:00:00
Installing collected packages: Pillow
Successfully installed Pillow-10.0.1
(.venv) ~/projects/segno-test> python
Python 3.11.5 (main, Aug 29 2023, 15:31:31) [GCC 13.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import segno
>>> qr = segno.make('A day in the life')
>>> img = qr.to_pil()
>>> img
<PIL.PngImagePlugin.PngImageFile image mode=1 size=29x29 at 0x7F2B698C7410>
>>>

The Python version is slightly newer but it shouldn't matter.

amzar96 commented 1 year ago

@heuer, it works now.

  1. pip install Pillow and it shows already installed
  2. I run again .to_pil() it works

I cannot determine the root cause, but I think the issue comes from my existing environment.

Thank you