0

i wrote this python script "mycv.py" in raspbian:

import cv2 as cv

and it debug and run currectly. then i use pyinstaller to make executable file. but when run file in terminal. it has error:

Traceback (most recent call last):
  File "mycv.py", line 1, in <module>
    import cv2 as cv
  File "/usr/local/lib/python3.7/dist-packages/PyInstaller/loader/pyimod03_importers.py", line 623, in exec_module
    exec(bytecode, module.__dict__)
  File "cv2/__init__.py", line 89, in <module>
  File "cv2/__init__.py", line 58, in bootstrap
  File "cv2/__init__.py", line 56, in load_first_config
ImportError: OpenCV loader: missing configuration file: ['config.py']. Check OpenCV installation.
[28400] Failed to execute script mycv

Any help is appreciated

1

1 Answer 1

0

After lots of debugging, I found the following solution:

  1. Get the path of OpenCV

    import cv2 print(cv2.file) # /usr/local/lib/python3.6/dist-packages/cv2/python-3.6/cv2.so

  2. Add this path while compiling through pyinstaller

    pyinstaller main.py -n myApp --paths="/usr/local/lib/python3.6/dist-packages/cv2/python-3.6"

I hope this helps others also

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.