qrtools icon indicating copy to clipboard operation
qrtools copied to clipboard

Cannot find 'QR' from 'qrtools'

Open sanderfoobar opened this issue 9 years ago • 15 comments

Just a message for those that are having trouble with from qrtools import QR or import qrtools; qrtools.QR()

I am using windows (py 3.5.0) and I got it to work by using:

from qrtools.qrtools import QR

As opposed to what the installation docs say.

Also; there seems to be a problem with the package 'zbar' as I cannot install it on my Windows machine but that's a problem with the zbar package.

sanderfoobar avatar Feb 11 '16 11:02 sanderfoobar

Thanx for the info skftn, this helped me out a lot...sort of. Still sitting with the zbar dependency now unfortunately. I found a zbar wrapper for python 3 which works, but not with this package obviously. Would it be possible to get these two to "work" together? Package name is zbar-ctypes

linuxson27 avatar Feb 11 '16 13:02 linuxson27

I have the same issue here, and your fix doesn't work (I use Linux)

micleb avatar Jul 26 '17 09:07 micleb

Some wrong with zbar installation, which only compitable with python 2.6 and bellow

wqw547243068 avatar Aug 17 '17 07:08 wqw547243068

If you are Mac OS user then do the following [1]: $ brew install zbar $ export LDFLAGS="-L$(brew --prefix zbar)/lib" $ export CFLAGS="-I$(brew --prefix zbar)/include" $ pip install zbarlight

If Debian then: $ apt-get install libzbar0 libzbar-dev $ pip install zbarlight # you can also use setuptools directly

This would take care of zbar issue for Python 3.X users! Took me 1 hours just to find this easy solution!

After this inside your python script import the following: from qrtools import qrtools from PIL import Image import zbarlight

Reference: 1) https://github.com/Polyconseil/zbarlight/

somdipdey avatar Mar 04 '18 20:03 somdipdey

Hi, the tips to use "from qrtools.qrtools import QR" helped me to resolve my problem but now i face another one who says : qr = qrtools.QR() NameError: name 'qrtools' is not defined

Do you have an idea to fix it ? Thanks.

Aziram avatar Jan 31 '19 13:01 Aziram

Hi, the tips to use "from qrtools.qrtools import QR" helped me to resolve my problem but now i face another one who says : qr = qrtools.QR() NameError: name 'qrtools' is not defined

Do you have an idea to fix it ? Thanks.

Try installing the qrtools as mentioned here: https://github.com/primetang/qrtools

somdipdey avatar Jan 31 '19 14:01 somdipdey

Thanks for the response, I've already done it with pip install qrtools and I've tried to clone the repo but nohting works. When i try to "import qrtools" I have the following error "qrtools has no module QR" and when I try to "from qrtools.qrtools import QR" I face the "name 'qrtools' is not defined" so I'm a bit lost ^^

Aziram avatar Jan 31 '19 14:01 Aziram

from qrtools import qrtools qr = qrtools.QR()

SimonPrudil avatar Jul 17 '19 09:07 SimonPrudil

from qrtools import qrtools qr = qrtools.QR()

It still give error: "ModuleNotFoundError: No module named 'zbar'" And I can't install zbar using pip: "ERROR: Command errored out with exit status 1: 'c:\users\astra\appdata\local\programs\python\python37-32\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Users\Astra\AppData\Local\Temp\pip-install-dfavmz_a\zbar\setup.py'"'"'; file='"'"'C:\Users\Astra\AppData\Local\Temp\pip-install-dfavmz_a\zbar\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' install --record 'C:\Users\Astra\AppData\Local\Temp\pip-record-5p25l52d\install-record.txt' --single-version-externally-managed --compile Check the logs for full command output."

Please help

Friday97 avatar Oct 17 '19 10:10 Friday97

same here

shreymukh avatar Feb 14 '20 07:02 shreymukh

Tried all the methods still have that error

vaishnavav99 avatar Aug 24 '20 04:08 vaishnavav99

well this post worked for me : https://www.codershubb.com/generate-or-read-qr-code-using-python/

saumy-mohit-13 avatar Jan 19 '21 11:01 saumy-mohit-13

Just use zbarlight (on Windows install it on WSL or try to compile it yourself):

from PIL import Image
import zbarlight

file_path = './qrcode.png'
with open(file_path, 'rb') as image_file:
    image = Image.open(image_file)
    image.load()

codes = zbarlight.scan_codes(['qrcode'], image)
print('QR codes: %s' % codes)

mardukbp avatar Jun 24 '22 11:06 mardukbp

The other solution is to use pyzbar, fast and simple. https://thecleverprogrammer.com/2022/01/18/decode-a-qr-code-using-python/

Andrej730 avatar Nov 12 '22 15:11 Andrej730

If you are Mac OS user then do the following [1]: $ brew install zbar $ export LDFLAGS="-L$(brew --prefix zbar)/lib" $ export CFLAGS="-I$(brew --prefix zbar)/include" $ pip install zbarlight

If Debian then: $ apt-get install libzbar0 libzbar-dev $ pip install zbarlight # you can also use setuptools directly

This would take care of zbar issue for Python 3.X users! Took me 1 hours just to find this easy solution!

After this inside your python script import the following: from qrtools import qrtools from PIL import Image import zbarlight

Reference: 1) https://github.com/Polyconseil/zbarlight/

I've done this and I have zbar and zbarlight installed, ostensibly. But I still can't seem to get qrtools to find it.

O_O [dj@deepai:~] $ brew install zbar
Warning: zbar 0.23.90_4 is already installed and up-to-date.
To reinstall 0.23.90_4, run:
  brew reinstall zbar
^_^ [dj@deepai:~] $ python
Python 3.12.0 (main, Dec 20 2023, 20:30:42) [Clang 15.0.0 (clang-1500.0.40.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from qrtools import qrtools
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/desco/.pyenv/versions/3.12.0/lib/python3.12/site-packages/qrtools/qrtools.py", line 28, in <module>
    import zbar
ModuleNotFoundError: No module named 'zbar'
>>> from PIL import Image
>>> import zbarlight
>>> from qrtools import qrtools
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/desco/.pyenv/versions/3.12.0/lib/python3.12/site-packages/qrtools/qrtools.py", line 28, in <module>
    import zbar
ModuleNotFoundError: No module named 'zbar'
>>>

DJStompZone avatar Dec 25 '23 02:12 DJStompZone