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

AttributeError: <class 'segno.QRCode'> object has no attribute to_artistic #378

Open
jpavonmCBRE opened this issue Sep 30, 2024 · 5 comments

Comments

@jpavonmCBRE
Copy link

I'm having an error when executing a python code with qrcode and qrcode-artistic when compiled with pyinstaller.
In my case, the code works when executing the python code as it is (as code by using 'python mycode.py'), BUT it does not work if I compile the code using pyinstaller. (pyinstaller does not return any error)

This is the error that I got when running the exe file:

  File "ORIGINAL_code.py", line 349, in <module>
  File "ORIGINAL_code.py", line 323, in main
  File "segno\__init__.py", line 970, in __getattr__
AttributeError: <class 'segno.QRCode'> object has no attribute to_artistic
[7552] Failed to execute script 'ORIGINAL_code' due to unhandled exception!

Line 349 calls the main() block.
Lines 322 and 323 have this code:

qr = helpers.make_wifi(ssid, guestPsk, security)
qr.to_artistic(background='green.png', target='QR-CODE.png', dark='#012A2D', data_dark='#003F2D', data_light='white', scale=8)
@heuer
Copy link

heuer commented Sep 30, 2024

Segno is a different project and not related or compatible to this project.

The "to_artistic" method is added to a QRCode object iff qrcode-artistic is installed, see https://segno.readthedocs.io/en/latest/artistic-qrcodes.html for details.

Since Segno should not have any dependencies and can natively create PNG without Pillow, a few functions that require Pillow have been outsourced to the qrcode-artistic project.

I have no experience with PyInstaller, but I suspect that the qrcode-artistic package is missing.

@jpavonmCBRE
Copy link
Author

No, the qrcode-artistic module is there, as I mentioned above, the code runs without any error or problem when executed as Python code file (code.py) but it does not run when compiled as .EXE file.

@heuer
Copy link

heuer commented Sep 30, 2024

As said, I have no experience with PyInstaller, but I suspect that PyInstaller does not recognize qrcode-artistic as a dependency because it is never explicitly imported and the method is added dynamically, at runtime, to the QRCode object.
Maybe this helps:
https://pyinstaller.org/en/stable/operating-mode.html#analysis-finding-the-files-your-program-needs

@jpavonmCBRE
Copy link
Author

But I finally found that removing the "DARK=" and "DATA_DARK=" attributes from "qr.to_artistic" it works.

@heuer
Copy link

heuer commented Sep 30, 2024

to_artistic supports data_dark etc.:

>>> qr.to_artistic(background='background.jpg', target='result.png', data_dark='green', data_light='yellow', dark='blue')

Please open an issue in Segno's repository if you encounter problems: https://github.com/heuer/segno

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

2 participants