I am currently working on a new project that involves CMC7 OCR reading. I was able to successfully execute the sample code on a Windows machine. However, I encountered an issue when attempting to run the same code on Linux.
I uploaded the code to an Ubuntu machine on AWS.
Next, I navigated to the directory "/ultimateMICR-SDK/binaries/linux/x86_64" and ran the following command:
"python3 ../../../python/setup.py build_ext --inplace -v".
This command generated the "_ultimateMicr.so" file, but with warnings:
============================================================
```
/*/ultimateMICR-SDK/binaries/linux/x86_64/../../../python/setup.py:8: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives
from distutils.core import setup, Extension
/*/ultimateMICR-SDK/binaries/linux/x86_64/../../../python/setup.py:9: DeprecationWarning: The distutils.sysconfig module is deprecated, use sysconfig instead
from distutils import sysconfig
Your platform: linux
running build_ext
building '_ultimateMicrSdk' extension
creating build
creating build/temp.linux-x86_64-3.10
creating build/temp.linux-x86_64-3.10/home
creating build/temp.linux-x86_64-3.10/*
creating build/temp.linux-x86_64-3.10/*/ultimateMICR-SDK
creating build/temp.linux-x86_64-3.10/*/ultimateMICR-SDK/python
x86_64-linux-gnu-gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I../../../c++ -I/usr/include/python3.10 -c /*/ultimateMICR-SDK/python/ultimateMICR-SDK-API-PUBLIC-SWIG_python.cxx -o build/temp.linux-x86_64-3.10/*/ultimateMICR-SDK/python/ultimateMICR-SDK-API-PUBLIC-SWIG_python.o
/*/ultimateMICR-SDK/python/ultimateMICR-SDK-API-PUBLIC-SWIG_python.cxx: In function ‘swig_type_info* SWIG_MangledTypeQueryModule(swig_module_info*, swig_module_info*, const char*)’:
/*/ultimateMICR-SDK/python/ultimateMICR-SDK-API-PUBLIC-SWIG_python.cxx:568:23: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
568 | register size_t l = 0;
| ^
/*/ultimateMICR-SDK/python/ultimateMICR-SDK-API-PUBLIC-SWIG_python.cxx:569:23: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
569 | register size_t r = iter->size - 1;
| ^
/*/ultimateMICR-SDK/python/ultimateMICR-SDK-API-PUBLIC-SWIG_python.cxx:572:25: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
572 | register size_t i = (l + r) >> 1;
| ^
/*/ultimateMICR-SDK/python/ultimateMICR-SDK-API-PUBLIC-SWIG_python.cxx:575:24: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
575 | register int compare = strcmp(name, iname);
| ^~~~~~~
/*/ultimateMICR-SDK/python/ultimateMICR-SDK-API-PUBLIC-SWIG_python.cxx: In function ‘swig_type_info* SWIG_TypeQueryModule(swig_module_info*, swig_module_info*, const char*)’:
/*/ultimateMICR-SDK/python/ultimateMICR-SDK-API-PUBLIC-SWIG_python.cxx:619:23: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
619 | register size_t i = 0;
| ^
/*/ultimateMICR-SDK/python/ultimateMICR-SDK-API-PUBLIC-SWIG_python.cxx: In function ‘char* SWIG_PackData(char*, void*, size_t)’:
/*/ultimateMICR-SDK/python/ultimateMICR-SDK-API-PUBLIC-SWIG_python.cxx:638:33: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
638 | register const unsigned char *u = (unsigned char *) ptr;
| ^
/*/ultimateMICR-SDK/python/ultimateMICR-SDK-API-PUBLIC-SWIG_python.cxx:639:33: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
639 | register const unsigned char *eu = u + sz;
| ^~
/*/ultimateMICR-SDK/python/ultimateMICR-SDK-API-PUBLIC-SWIG_python.cxx:641:28: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
641 | register unsigned char uu = *u;
| ^~
/*/ultimateMICR-SDK/python/ultimateMICR-SDK-API-PUBLIC-SWIG_python.cxx: In function ‘const char* SWIG_UnpackData(const char*, void*, size_t)’:
/*/ultimateMICR-SDK/python/ultimateMICR-SDK-API-PUBLIC-SWIG_python.cxx:653:27: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
653 | register unsigned char *u = (unsigned char *) ptr;
| ^
/*/ultimateMICR-SDK/python/ultimateMICR-SDK-API-PUBLIC-SWIG_python.cxx:654:33: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
654 | register const unsigned char *eu = u + sz;
| ^~
/*/ultimateMICR-SDK/python/ultimateMICR-SDK-API-PUBLIC-SWIG_python.cxx:656:19: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
656 | register char d = *(c++);
| ^
/*/ultimateMICR-SDK/python/ultimateMICR-SDK-API-PUBLIC-SWIG_python.cxx:657:28: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
657 | register unsigned char uu;
| ^~
/*/ultimateMICR-SDK/python/ultimateMICR-SDK-API-PUBLIC-SWIG_python.cxx: In function ‘int SWIG_Python_UnpackTuple(PyObject*, const char*, Py_ssize_t, Py_ssize_t, PyObject**)’:
/*/ultimateMICR-SDK/python/ultimateMICR-SDK-API-PUBLIC-SWIG_python.cxx:1334:20: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
1334 | register int i;
| ^
/*/ultimateMICR-SDK/python/ultimateMICR-SDK-API-PUBLIC-SWIG_python.cxx:1344:25: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
1344 | register Py_ssize_t l = PyTuple_GET_SIZE(args);
| ^
/*/ultimateMICR-SDK/python/ultimateMICR-SDK-API-PUBLIC-SWIG_python.cxx:1354:20: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
1354 | register int i;
| ^
In file included from /usr/include/string.h:535,
from /usr/include/python3.10/Python.h:30,
from /*/ultimateMICR-SDK/python/ultimateMICR-SDK-API-PUBLIC-SWIG_python.cxx:149:
In function ‘char* strncpy(char*, const char*, size_t)’,
inlined from ‘void SWIG_Python_FixMethods(PyMethodDef*, swig_const_info*, swig_type_info**, swig_type_info**)’ at /*/ultimateMICR-SDK/python/ultimateMICR-SDK-API-PUBLIC-SWIG_python.cxx:5499:22,
inlined from ‘PyObject* PyInit__ultimateMicrSdk()’ at /*/ultimateMICR-SDK/python/ultimateMICR-SDK-API-PUBLIC-SWIG_python.cxx:5597:25:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:95:34: warning: ‘char* __builtin_strncpy(char*, const char*, long unsigned int)’ output truncated before terminating nul copying 10 bytes from a string of the same length [-Wstringop-truncation]
95 | return __builtin___strncpy_chk (__dest, __src, __len,
| ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
96 | __glibc_objsize (__dest));
| ~~~~~~~~~~~~~~~~~~~~~~~~~
x86_64-linux-gnu-gcc -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -g -fwrapv -O2 -Wl,-Bsymbolic-functions -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 build/temp.linux-x86_64-3.10/*/ultimateMICR-SDK/python/ultimateMICR-SDK-API-PUBLIC-SWIG_python.o -L. -lultimate_micr-sdk -o /*/ultimateMICR-SDK/binaries/linux/x86_64/_ultimateMicrSdk.so
```
============================================================
Afterwards, I moved to the directory "/ultimateMICR-SDK/samples/python/recognizer" and executed the following command:
```
PYTHONPATH=../../../binaries/linux/x86_64:../../../python \
LD_LIBRARY_PATH=../../../binaries/linux/x86_64:$LD_LIBRARY_PATH \
python3 recognizer.py --image ../../../assets/images/e13b_1280x720.jpg --format e13b --assets ../../../assets --backprop True --ielcd True
```
However, I encountered an error, which is displayed below:
============================================================
Traceback (most recent call last):
File "/*/ultimateMICR-SDK/python/ultimateMicrSdk.py", line 16, in swig_import_helper
fp, pathname, description = imp.find_module('_ultimateMicrSdk', [dirname(__file__)])
File "/usr/lib/python3.10/imp.py", line 297, in find_module
raise ImportError(_ERR_MSG.format(name), name=name)
ImportError: No module named '_ultimateMicrSdk'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/*/ultimateMICR-SDK/samples/python/recognizer/recognizer.py", line 27, in <module>
import ultimateMicrSdk
File "/*/ultimateMICR-SDK/python/ultimateMicrSdk.py", line 26, in <module>
_ultimateMicrSdk = swig_import_helper()
File "/*/ultimateMICR-SDK/python/ultimateMicrSdk.py", line 18, in swig_import_helper
import _ultimateMicrSdk
ImportError: libtensorflow.so.1: cannot open shared object file: No such file or directory
============================================================
run next commands and share the outputs:
$ g++ --version
$ ls -l ultimateMICR-SDK/binaries/linux/x86_64
I see this error in your logs: "ImportError: libtensorflow.so.1: cannot open shared
object file: No such file or directory"
Quote from https://github.com/DoubangoTelecom/ultimateMICR-SDK/tree/master/samples/python/recognizer: "Before trying to run the program you'll need to download libtensorflow.so as explained here"
you didn't install Tensorflow as explained
on the guide. "libtensorflow.so.1" must be present
in the binaries folder.
You said it's working with Windows, it's because we have tensorflow included while you have to install it for Linux. You need to unzip the Tensorflow binaries as explained on the guide.
--
You received this message because you are subscribed to the Google Groups "doubango-ai" group.
To unsubscribe from this group and stop receiving emails from it, send an email to doubango-ai...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/doubango-ai/72ef58ac-105a-4086-afbd-399de937da67n%40googlegroups.com.
Thank you for your response.
I have downloaded the zipped tensorflow file (tried 3 and 4) and extracted its contents in the binaries folder as the instructions,
I executed from the recognizer folder:
```
PYTHONPATH=../../../binaries/linux/x86_64:../../../python LD_LIBRARY_PATH=../../../binaries/linux/x86_64:$LD_LIBRARY_PATH sudo python3 recognizer.py --image ../../../assets/images/e13b_1280x720.jpg --format e13b --assets ../../../assets --backprop True --ielcd True
```
The error:
```
Traceback (most recent call last):
File "/*/ultimateMICR-SDK/samples/python/recognizer/recognizer.py", line 27, in <module>
import ultimateMicrSdk
ModuleNotFoundError: No module named 'ultimateMicrSdk'
```
I have executed the commands you requested:
$ g++ --version
g++ (Ubuntu 11.3.0-1ubuntu1~22.04.1) 11.3.0
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ ls -l ultimateMICR-SDK/binaries/linux/x86_64
-rw-rw-r-- 1 * 74 Jun 22 10:40 README.md
-rwxr-xr-x 1 * 272680 Jun 22 11:08 _ultimateMicrSdk.so
-rw-rw-r-- 1 * 141224 Jun 22 10:40 benchmark
drwxr-xr-x 3 * 4096 Jun 22 08:22 build
-rw-rw-r-- 1 * 0 Jun 22 10:55 libtensorflow.so
-rw-rw-r-- 1 * 0 Jun 22 10:42 libtensorflow.so.1
-rw-rw-r-- 1 * 382810991 Jun 22 10:54 libtensorflow.so.1.14.0
-rw-rw-r-- 1 * 0 Jun 22 10:54 libtensorflow_framework.so
-rw-rw-r-- 1 * 0 Jun 22 10:54 libtensorflow_framework.so.1
-rw-rw-r-- 1 * 35655504 Jun 22 10:55 libtensorflow_framework.so.1.14.0
-rw-rw-r-- 1 * 3749392 Jun 22 10:40 libultimate_micr-sdk.so
-rw-rw-r-- 1 * 55 Jun 22 10:40 python_setup.sh
-rw-rw-r-- 1 * 136504 Jun 22 10:40 recognizer
-rw-rw-r-- 1 * 28376 Jun 22 10:40 runtimeKey
The command you said you have executed is a single line with values concatenated, I'm not comfortable about it. You should run it as on the guide, with backslashes
`PYTHONPATH=../../../binaries/linux/x86_64:../../../python` is what will fix your issue, notice the bold part, it's the folder where ultimateMicrSdk.py is located. You can also change the relative path to absolute
To view this discussion on the web visit https://groups.google.com/d/msgid/doubango-ai/ecd0190f-35fd-49f1-a8c1-feb952320717n%40googlegroups.com.
I have tried the instructions from scratch
on a PC with gcc version 9.4.0 (Ubuntu 9.4.0-1ubuntu1~20.04.1)
and Python 3.8.5 ...it works fine
Do it the dirty way:
Copy https://github.com/DoubangoTelecom/ultimateMICR-SDK/blob/master/python/ultimateMicrSdk.py to:
- ultimateMICR-SDK/binaries/linux/x86_64
- and ultimateMICR-SDK/samples/python/recognizer
Or/and, in recognizer.py add (before the import):
sys.path.append('absolute path to ultimateMICR-SDK/blob/master/python/ultimateMicrSdk.py')
To view this discussion on the web visit https://groups.google.com/d/msgid/doubango-ai/5cb60dc5-a9e1-41b9-a6db-11d5af8f9365n%40googlegroups.com.
I followed your suggestion, but it appears that we have a similar error as before:
===========================================
Traceback (most recent call last):
File "/*/ultimateMICR-SDK/samples/python/recognizer/ultimateMicrSdk.py", line 17, in swig_import_helper
fp, pathname, description = imp.find_module('_ultimateMicrSdk', [dirname(__file__)])
File "/usr/lib/python3.10/imp.py", line 297, in find_module
raise ImportError(_ERR_MSG.format(name), name=name)
ImportError: No module named '_ultimateMicrSdk'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/*/ultimateMICR-SDK/samples/python/recognizer/recognizer.py", line 33, in <module>
import ultimateMicrSdk
File "/*/ultimateMICR-SDK/samples/python/recognizer/ultimateMicrSdk.py", line 27, in <module>
_ultimateMicrSdk = swig_import_helper()
File "/*/ultimateMICR-SDK/samples/python/recognizer/ultimateMicrSdk.py", line 19, in swig_import_helper
import _ultimateMicrSdk
ModuleNotFoundError: No module named '_ultimateMicrSdk'
===========================================
Does binaries/linux/x86_64/_ultimateMicrSdk.so exists ?
also try with the C++ sample to see if it works:
$ cd binaries/linux/x86_64
$ LD_LIBRARY_PATH=.:$LD_LIBRARY_PATH
./recognizer \
--image ../../../assets/images/e13b_1280x720.jpg \
--assets ../../../assets \
--formay e13b+cmc7 \
--backprop true
will tell you if there are dependency
issues (preventing the ext to load) or not.
To view this discussion on the web visit https://groups.google.com/d/msgid/doubango-ai/35a25090-6b15-4fd2-a083-890ceed7a388n%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/doubango-ai/aa4cdb25-b3b4-401f-a0ae-95647e34f683n%40googlegroups.com.
On 27 Jun 2023, at 14:45, Mamadou DIOP <diopm...@doubango.org> wrote:What I was asking is to run the sample (not to build it), so that we’ll know if there are dependency issues:to build the sample: $g++ recognizer.cxx -O3 -I../../../c++ -L../../../binaries/linux/x86_64 -Wl,-rpath=../../../binaries/linux/x86_64 -lultimate_micr-sdk -ltensorflow_framework -o recognizer
To view this discussion on the web visit https://groups.google.com/d/msgid/doubango-ai/F16789A7-A54E-485D-B67A-660BE4B9BFF1%40doubango.org.
On 27 Jun 2023, at 14:50, Ron David <r...@jetweb.co.il> wrote:Thank you for your assistance!I successfully resolved the issue by fixing the broken symlink in the extracted TensorFlow files.
To view this discussion on the web visit https://groups.google.com/d/msgid/doubango-ai/6cb888ac-8a52-407d-a199-cfa6c69317bfn%40googlegroups.com.
Yes, I unzipped a folder on Windows into a Linux environment, which seems to break the symlink.