I am using Windows 10 and I want to install openalpr and import the library to python.
However, after downloaded the Pre-compiled Windows binaries, I dont know how ti import alpr in python
I follow the instruction in OpenAlpr
I downloaded the openalpr-2.3.0-win-64bit.zip here and unzipped it.
Afterwards, I can run alpr
in command line but I cannot import it.
Can anyone teach me how I can import Openalpr in python. Thank you.
It looks like you need to add the OpenALPR to the system path (step 4 below) and install the Python bindings (step 5 below). This is how I got OpenALPR to work on Windows 7/Anaconda 3/python 3.5 x64:
You should uninstall any previous version of ALPR
Download the binaries and the source code from https://github.com/openalpr/openalpr/releases
Unzip the binaries and the source code in some directory, for example
C:\OpenALPR
Add the directory where alpr is located to your PATH. In my case
C:\OpenALPR\openalpr_64
Use Anaconda Prompt to install the Python bindings (they are in the source code directory). In my case:
Output:
Now there is a problem with the unload method of the DLL, but that is another issue:
Exception ignored in: <bound method Alpr.__del__ of <openalpr.openalpr.Alpr object at 0x0000000002C04198>>
. BTW this problem only happen when using alpr.unload().When you've downloaded the binary distribution, navigate to
python
subdirectory and runpython setup.py
. This would install OpenALPR as package, so then you would be able to import it from anywhere, not just from ALPR's directory.Explaination: To be importable, it requires that the package you're trying to import been else:
python
PYTHONPATH
environment variable.pth
filessite-packages
dirsys.path
by handAnd when you run
setup.py
script, it kicks distutils to properly copy package's distribution tosite-packages
, thus adding it to your libs.For more information, see setup.py usage and how import system works
I setted up the same environment as you:
C:\Users\user\Anaconda
C:\Users\user\Downloads\openalpr-2.3.0-win-64bit
So I can call
python
from the console (cmd
) and get:The module
As the bindings are not shipped with the pre-compiled Windows binaries, you have to install the module manually:
C:\Users\user\Downloads\openalpr-master
;C:\Users\user\Downloads\openalpr-master\src\bindings\python
folder;python setup.py install
Voilà, the Python module OpenAlpr is installed!.
Call
python_test.bat
from the OpenAlpr directory to see it works.Usage
To be able to import OpenAlpr module from Python, two solutions.
Solution 1: you will need to work into the OpenAlpr directory where DLL files are located. Then, it should works as expected:
Solution 2 (best I think): you update the
PATH
to include the OpenAlpr folder: