lincolnloop / python-qrcode

Python QR Code image generator
https://pypi.python.org/pypi/qrcode
Other
4.39k stars 674 forks source link

AttributeError: 'str' object has no attribute 'write' #306

Closed Nicolalorettu closed 1 year ago

Nicolalorettu commented 1 year ago

I tried the library in both linux vm and windows 11 with the same results

import qrcode img = qrcode.make("https://www.youtube.com/") img.save("youtubeQR.jpg")

texnofobix commented 1 year ago

I had to install pip install qrcode[pil], and it worked. Looks like it should work without it, so the issue is valid.

SmileyChris commented 1 year ago

This should work now without pil (although it'll be a png file even if you called it "something.jpg") in the version I just released.

Previously the pure png factory needed :

with open("youtubeQR.jpg", "wb") as f:
    img.save(f)