I am pretty new to programming, and have never used Zbar before. I am trying to write a simple script that will allow me to import Zbar and use it to decode a barcode image. I already have a script set up to decode text from images that uses Pytesseract and Tesseract OCR, but I need to be able to decode barcodes as well. I have Windows 7 32 bit, and and am using Python 3.4. I have already installed Zbar and have used it from the command line successfully to decode their barcode sample. I have tried using >pip install zbar, but I keep getting the error:
"fatal error C1083: Cannot open include file: 'zbar.h': No such file or directory
error: command 'C:\Program Files\Microsoft Visual Studio 10.0\VC\BIN\cl.exe' failed with exit status 2"
Getting the pytesseract OCR was painless but I have wasted a lot of time on this barcode portion of it, any help or alternatives would be much appreciated.
Seven months later you accepted the best answer, a simple solution for
python3.4+ on Windows OS appeared. A ctypes-based wrapper around the zbar barcode reader, a package named pyzbar. If you are on Linux, you need to install libzbar0 but you said you are using Windows and the zbar library is included as dll with the Windows Python wheels. Today, all you need to do is launch:
pip install pyzbar
References for the package:
https://pypi.python.org/pypi/pyzbar
https://github.com/NaturalHistoryMuseum/pyzbar/
I thought I'd share my explorations and discoveries in relation to this problem, even though #ltadams21 has found a workaround.
The short answer: You can't. The zbar module is only compatible with Python 2. The incompatibilities are at the level of the Python C API, which is deep magic beyond my ken.
There's a bug report for this. In the meantime, use the os.system workaround that #ltadams21 posted, or maybe try zbarlight instead? (I haven't tried it myself, because it says it only reads QR codes, and I need something that reads EAN barcodes.)
The long answer: You can follow along with these steps, which represent my best efforts to get it working, but (spoiler alert) it still won't work at the end.
(Re)install zbar for Windows (zbar-0.10-setup.exe), making sure to tick the "Development Headers and Libraries" option.
Download and extract the zbar Python package (zbar-0.10.tar.bz2).
Open setup.py in your preferred text editor.
Scroll to the bottom, find the line that starts libraries, and insert a new line below it, like so (checking that the path is the same on your system as it is on mine):
libraries = [ 'zbar' ],
include_dirs = ['C:/Program Files (x86)/ZBar/include'],
Open a command prompt inside the extracted package and run python setup.py install.
Observe that the new errors now relate to PyIntObject and PyInt_Type. Discover that these are Python 2-only objects.
If desperate, try to re-#define them to use PyLongObject and PyLong_Type instead. Fail, because of course it's not that easy. Bang head against keyboard (gently).
Give up, and use the os.system workaround that #ltadams21 posted.
Forget wrestling with all of the wrappers. The easiest solution for me was to simply use
import os
os.system(r'D:\Winapps\Zbar\bin\zbarimg.exe -d d:\Winapps\Zbar\Examples
\barcode.png')
Worked instantly. Hope this helps anyone else struggling with that issue.
As of November 2016, there is the package pyzbar. To import Zbar for python3.4+ on Windows OS, all you need to do is launch
pip install pyzbar
This is possible because pyzbar is a ctypes-based wrapper around the zbar library that is included as dll with the Windows Python wheels.
The ZBar for python says you need to have the ZBar library installed for it to work. http://zbar.sourceforge.net/download.html
I found an easy solution for 3.4+. First install pyzbar
pip install pyzbar.
Then the below should work
import pyqrcode
from pyzbar.pyzbar import decode
from PIL import Image
qr = pyqrcode.create("HORN O.K. PLEASE.")
qr.png("horn.png", scale=6)
decode(Image.open('horn.png'))
print(qr.data)
Related
I try since multiple days to install solaris (https://github.com/CosmiQ/solaris) locally, on google colab or on renkulab (https://renkulab.io/). Up to now, without any luck. I tried on all platform different approaches:
Creating a conda environment (as recommended by the authors)
Directly through pip
And also cloning the repository and access the folders and functions directly
All of these approaches failed so far. Mostly there is a wheel building error for GDAL. Which i have installed first. I do not find any proper documentation or other failure descriptions which makes me question myself... Maybe here someone has experience with this library?
I highly appreciate every hint.
Thanks a lot
Colab Setup
I can get it set up in Colab with the following:
First Cell: Install Mamba/Conda
!pip install -q condacolab
import condacolab
condacolab.install()
This will trigger a runtime restart - it does this on purpose.
Second Cell: Install Solaris prerequisites
I'm assuming we want the GPU-enabled version. If not, there is another YAML in the solaris repository for a CPU-only environment.
!wget https://raw.githubusercontent.com/CosmiQ/solaris/main/environment-gpu.yml
!mamba env update -n base -f environment-gpu.yml
Manually restart the runtime after this completes!
Third Cell: Install Solaris
!pip install solaris
That should be it. Following these steps, I could import the module and use the entrypoints, e.g.,
Module import ✅
import solaris
Example entrypoint ✅
!make_masks -h
There were some future deprecation warnings from NumPy about some syntax in the TensorFlow code, but otherwise, seems functional. However, I don't personally use this tool, so I don't know if there is more to verify.
I would like to use the package HDF5
In my Pluto.jl, I have the line
using HDF5
When I try to evaluate this cell, I get the error message
"ERROR: LoadError: HDF5 is not properly installed. Please run Pkg.build("HDF5") and restart Julia."
I would like to do this, but when I go to the terminal, I can't do this while I have Pluto open.
I've tried running Pluto in the background with a command like
Pluto.run() &
But this code is completely wrong.
I've also heard that there sometimes appears a cloud icon above the cell, which would allow me to download HDF5 directly.
In any case, it seems to me like any time this happens, I will have to write down which package I need to install, and then kill my Pluto notebook, go to Julia, install, and restart Julia. Surely there is a better way? Can anyone help me find it?
When the package is correctly installed or could be installed without problems, using HDF5 in Pluto itself is sufficient. The built-in Pluto package manager takes care about the installation.
There are edge cases where due to issues with external packages installation does not work out-of-the-box. In this case, it could help to install the package in a temp environment before starting Pluto:
] activate --temp
] add HDF5
follwed by whatever steps required to get the package working in Julia itself, like re-building it.
This should really be a workaround and should be fixed in the corresponding package - consider creating an Issue there if it does not exist already.
Please, I do need a light here. I want to install numpy using a good BLAS/LAPACK lib on Windows, but absolutely no page explains the process well enough. It seems OpenBLAS is a good and fast option.
The goal is to use "theano" with "keras", and "theano" requires that the libraries be "dynamic", not static. (Not sure I understand what that means, but it causes slowness and memory issues)
Please treat me as a complete newbie. Give me a step by step tutorial on how to do it! Don't forget to tell me "where" files should go! Which folders should go in PATH! What commands exactly I should call, and what are their output, where? What do I do with their results or with compiled files? How does numpy find them? Etc. All the sites I've seen seem to think I'm a linux expert and already know everything.
What I have tried:
Downloaded the compiled version of numpy+mkl from here -- This does install numpy, it becomes usable, but theano presents the memory leak problem, besides working slowly. Is it a matter of setting the right ldflags in the .theanorc file? If so, which are the flags? - About the MKL libraries, this answer may be useful?
Tried installing Anaconda - it doesn't work either, and I had no idea about what went wrong. It gave me messages suggesting installing some extra stuff, it worked but incredibly slow. More than 10 times slower than my bugged numpy version mentioned above (so, unacceptable, impossible to work at that speed). If I have to go changing everything about Anaconda, it's better to use a regular python instead and know what is going on.
Found these already compiled BLAS/LAPACK libraries (.dll and .lib) files. But.... what am I supposed to do with them? -- Simply adding their folders to the PATH var and installing numpy gives me "numpy-atlas", not the libraries I downloaded. How do I make numpy see them?
Tried to understand this page, but yet, it seems it will lead me exactly to the previous case, what will I do with the results? Where are the libs they suggest I use? What are the suggested quickbuild scripts, where are they?
Found the Cygwin option here. I haven't tried it, but it sounds it should be something easier than reinstalling all my python and packages, all from Cygwin
Year 2021: this works with miniconda on Windows 10
conda create -n openblas python=3.8
conda activate openblas
conda install conda-forge::blas=*=openblas
conda install -c conda-forge numpy
Tested also with matplotlib-base.
Tried following the building instructions in http://scipy.github.io/devdocs/building/windows.html a number of times without success.
[MY SOLUTION]
After extensive reading of the logs and related forums, came up with a method that has worked for me in two windows machines already. Posted a batch file with the steps I used in https://github.com/jhvital/build-scipy-openblas.
The show_config method shows linkage to openblas libraries, and this was confirmed by comparing the runtimes of scripts against the scipy installed with conda install scipy, which installs the mkl package.
Still I'm not entirely sure whether the libraries were linked correctly. Feedback would be appreciated.
The build instructions for SciPy is tested a number of times and it seems to be working.
You can find the instructions here http://scipy.github.io/devdocs/building/windows.html
Note that this is still a very delicate procedure and needs to be done very carefully. It still does not guarantee success thanks to Windows being Windows. However please take the time to report any issues should you encounter any at https://github.com/scipy/scipy.org/issues (notice it is not the scipy repo but but scipy.org repo)
I am not sure what's the error you have recieved when trying to get openblas & numpy using anaconda.
For openblas on windows using anaconda3 python 3.6v this works:
conda install -c menpo openblas
ref: https://anaconda.org/menpo/openblas
For numpy:
it is :conda install numpy. if you are looking for a specific version of numpy use: conda install numpy=version_number
I know that similar- questions about installing modules in Portable Python have been
asked but I have looked at all of them and another website. I didn't have success.
For me, I wanted to install Pygame on Portable Python 3.2.5.1 (on a memory stick). I nearly
managed to install it successfully but when I typed import pygame into the shell window,
there was a weird error in one of the files, displayed in the shell. See image below:
Update: Portable Python at time of writing has been discontinued (not being developed anymore)
and there are other alternatives available in suggested links on their website or internet search
engine query results. I have managed to add the Pygame Python module to my version
of one of these continuing projects so this question is not of use to me anymore.
I had this same problem today. I may have managed it. This is what I did:
I installed pygame to an empty folder so I could see all the things it needed. this was two folders:
Include>pygame and
Lib>site-packages
I went to Lib>site-packages and copied all the things there, then pasted them into
G:\Portable Python 3.2.5.1\App\Lib\site-packages
I also copied all the things in:
G:\Include\pygame
and pasted them into:
G:\Portable Python 3.2.5.1\App\include
from a quick play, this seems to work.
Although it isn't really the proper answer I was looking for a while ago when I posted the question (how to install Pygame on Portable Python 3.2.5.1), I have a possible answer for my question that could work.
It is possible (although I haven't personally tested it yet) run a Python
program using Portable Python and with the Pygame library folder stored in the directory the program is stored in. Python's module search path includes the current directory (of the running file) so import pygame would import it.
This question is old and maybe this is a possibility that was not possible at this time but simply:
From a command prompt go to your Portable Python's python.exe folder with cd <path to Portable Python>\App\Python,
Run: .\python.exe -m pip install pygame,
Now you have pygame module installed, you can check in your <path to Portable Python>\App\Python\Lib\site-packages that you have now pygame.
Note: I used Portable Python from here, version 3.10.5 at the time I wrote this.
I have just downloaded the youtube-dl-2014.07.15.tar_2.gz in my windows. At first I want to tell I don't know anything about python. And I already have installed python 2.7. Can anyone give me instruction to execute these scripts?
I have already tried to run...but there is some error like these. "No mudule named youtube-dl"
I want a fresh start. Now I am using windows 8.1 and I have also tried youtube-dl.exe. And there is also problem like screenshot
If I want to get worked both script and program what will I do?Any helps will be appreciated. If you give me instruction from scratch that will be better.
To install youtube_dl in Python on Windows (command from their github):
Tested with Python 3.9 on Windows 10
pip install --upgrade youtube-dl
Now when using it, notice that the name of the Python module is with an underscore.
Because it is a Python module, use it like so:
py -m youtube_dl <video url>
Of course video url is the video you want to download
This seems to be caused by a limitation of py2exe. You may want to file a youtube-dl bug report for moving to a cxfreeze, which should not have that problem. In any case, simply moving the youtube-dl.exe file into another directory such as C:\Users\Shamim should fix the problem.
you need just to put the youtube-dl.exe file in in your home directory or any other location on your PATH.
You can see your PATH in your "Envirenment Variables"