I have a software which I packaged in x86 processors using pyinstaller and it packages all libraries including cv2, however, when I try to package the same software in Jetson TX2, it doesn't package cv2 and throws error on executing the binary file:
OpenCV loader: missing configuration file: ['config.py']
The reason is cv2 comes preinstalled in TX2 at a different location (/usr/lib/python3.6/dist-packages
). However, rest of the libraries which we self-installed are in (/home/mnauf/.local/lib/python3.6/site-packages
) and maybe this is why pyinstaller fails to package it.
The pyinstaller tries to find cv2 at /home/mnauf/.local/lib/python3.6/site-packages
and doesn't find there and correspondingly doesn't package, however cv2 imports fine if you do it with python. The reason why cv2 works fine with python is that I suppose python first tries to find a library in /home/mnauf/.local/lib/python3.6/site-packages
and if unsuccessful, finds in /usr/lib/python3.6/dist-packages
.
To solve the packaging problem, I tried the following methodologies and the errors discussed below all come when executing the binary file and don't come at the time of packaging:
- Copying cv2 from
/usr/lib/python3.6/dist-packages
to/home/mnauf/.local/lib/python3.6/site-packages
. It gives:
ImportError: ERROR: recursion is detected during loading of "cv2" binary extensions. Check OpenCV installation.
I try to copy cv2 directory from
/usr/lib/python3.6/dist-packages
todist/main
folder created by pyinstaller after packaging but I get the same Import error.Adding the cv2 directory path as a data file in
main.spec
also only copies the folder todist/main
and hence gives the same Import error.Adding the
cv2.cpython-36m-aarch64-linux-gnu.so
path only as a data file in main.spec givesOpencv loader
error.Adding the cv2 directory as a binary file path in main.spec gives the
Import error
.Adding the
cv2.cpython-36m-aarch64-linux-gnu.so
path only as a binary file in main.spec gives theOpencv loader
error.
Please help me with packing cv2. Thanks