Python unable to load OpenALPR, working fine in CLI

1.6k Views Asked by At

I'm trying to install OpenALPR on my Raspberry Pi, with Raspbian 4.19 and Python 3.7.

I followed this guide to install OpenAlpr and it works fine when called from the CLI. I'm now trying to make it work in a little python script, but I can't even load OpenAlpr. My code:

from openalpr import Alpr
import json
import sys
from time import sleep
alpr = Alpr("eu", "/etc/openalpr/openalpr.conf",
            "/usr/share/openalpr/runtime_data")
analysis = alpr.recognize_file("./500front.jpg")
print(json.dumps(analysis, indent=4))

when ran with sudo python3 testscript.py the following error happens:

Traceback (most recent call last):
  File "testingcamera.py", line 6, in <module>
    "/usr/share/openalpr/runtime_data")
  File "/usr/local/lib/python3.7/dist-packages/openalpr/openalpr.py", line 85, in __init__
    self._recognize_raw_image_func = self._openalprpy_lib.recognizeRawImage
  File "/usr/lib/python3.7/ctypes/__init__.py", line 369, in __getattr__
    func = self.__getitem__(name)
  File "/usr/lib/python3.7/ctypes/__init__.py", line 374, in __getitem__
    func = self._FuncPtr((name_or_ordinal, self))
AttributeError: /usr/lib/libopenalprpy.so: undefined symbol: recognizeRawImage
Exception ignored in: <function Alpr.__del__ at 0x76598198>
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/dist-packages/openalpr/openalpr.py", line 258, in __del__
    if self.is_loaded():
  File "/usr/local/lib/python3.7/dist-packages/openalpr/openalpr.py", line 135, in is_loaded
    if not self.loaded:
AttributeError: 'Alpr' object has no attribute 'loaded'
1

There are 1 best solutions below

0
On

It looks like a mis-match between the version of the ALPR library installed and the version of the python bindings.

See here: https://github.com/openalpr/openalpr/issues/311