Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
QR Codes
#1
Hi all,
I'm trying to generate qr codes in python. I have downloaded and did a pip install of qrcode on the pypi site.
The starter code on the site is:
import qrcode
import qrcode.image.svg
img = qrcode.make('Sacmap')
type(img) #qrcode.image.pil.PilImage
img.save('Sacmap pic.svg')
I keep getting this error:
Error:
Traceback (most recent call last): File "C:/Users/araki/QR_C0DE/qrcode.py", line 2, in <module> import qrcode File "C:\Users/araki/QR_C0DE\qrcode.py", line 3, in <module> import qrcode.image.svg ModuleNotFoundError: No module named 'qrcode.image'; 'qrcode' is not a package >>>
So, the question is where is 'pil' and why don't I have it installed in my default folder?

Thanks for any help,
"Human history becomes more and more a race between education and catastrophe." - H. G. Wells (1866-1946)
Reply
#2
You have a file in your directory named qrcode.py. This is blocking (shadowing) the qrcode module. Python finds your file first when looking for the module.

Rename your file to something else so it doesn't conflict with the module name.
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020