Reputation: 2808
How can I decode a qr code in python 3.6 in Anaconda 4.8.3 a Windows 10 Pro N 64 bit installation?
Most solutions require Pillow with zbar
. However, it appears zbar
is only available on 32bit
windows installations. Furthermore, pip install zbarlight
yields:
ERROR: No matching distribution found for pyzbarlight
To try and decode a qr code in python 3.6 in Anaconda 4.8.3 on a Windows 10 Pro N 64 bit device, I tried the following code:
# Set up virtual environment in Anaconda
# conda create --name test36 python=3.6
# conda activate test36
# Install pip in the `test36` environment:
# E:/ProgramData/Anaconda3/envs/test36/Scripts/pip install pyzbar
# Source: https://anaconda.org/anaconda/pillow
# conda install -c anaconda pillow
from pyzbar.pyzbar import decode
from PIL import Image
decode(Image.open('elbow.png'))
Which yields error:
OSError: [WinError 126] The specified module could not be found
Upvotes: 0
Views: 2023
Reputation: 2808
To recap the following steps enabled decoding a qr code in a python 3.6 environment in Anaconda prompt 4.8.3 on a 64 Windows 10 Pro N device:
The steps assume python 3.6 environment is installed and activated, which can be done with.
conda create -n py36 python=3.6 anaconda
conda activate py36
Source:https://anaconda.org/conda-forge/pillow
Command:
conda install -c conda-forge pillow
Source: Decode a qr-code in Python 3.6 in Anaconda 4.8.3 on 64 bit Windows?
Command:
pip install pyzbar
Then from source: https://www.microsoft.com/en-US/download/details.aspx?id=40784
download vcredist_x64.exe
(if you have an 64 bit pc, for x86 pick the 32 bit version).
You don't even have to restart anaconda prompt and you can verify pyzbar with a python file named test.py
with content:
from pyzbar.pyzbar import decode
decode(Image.open('test.png'))
Next include an image named test.png
in the same folder as test.py
.
You can execute test.py
in Anaconda prompt in a python 3.6 environment with command:
python test.py
It shouldn't output anything.
Upvotes: 0
Reputation: 2028
Windows error message
If you see an ugly ImportError when importing pyzbar on Windows you will most likely need the Visual C++ Redistributable Packages for Visual Studio 2013. Install vcredist_x64.exe if using 64-bit Python, vcredist_x86.exe if using 32-bit Python.
visit and read please here https://pypi.org/project/pyzbar/ or github homepage https://github.com/NaturalHistoryMuseum/pyzbar
I use Ubuntu for my purposes, so I cannot check this out, but in home project README they give information about ugly ImportError. If they talk about 64 bit installation, then pyazbar works on 64-bit Windows, please doublecheck that Visual C++ Redistributable Packages for Visual Studio 2013 is properly installed and other requirements are satisfied also.
Upvotes: 1