Opencv installation

Question: how to import opencv

I tried to download the opencv-python in packages then import it, but somehow it doesn’t work as I expected.


import cv2


Traceback (most recent call last):
  File "", line 3, in <module>
    import cv2
  File "/home/runner/DASC2110-final-project-non-OOP/venv/lib/python3.10/site-packages/cv2/", line 181, in <module>
  File "/home/runner/DASC2110-final-project-non-OOP/venv/lib/python3.10/site-packages/cv2/", line 111, in bootstrap
    load_first_config([''], True)
  File "/home/runner/DASC2110-final-project-non-OOP/venv/lib/python3.10/site-packages/cv2/", line 109, in load_first_config
    raise ImportError('OpenCV loader: missing configuration file: {}. Check OpenCV installation.'.format(fnames))
ImportError: OpenCV loader: missing configuration file: ['']. Check OpenCV installation.

If I use import opencv-python instead of import cv2, it gives SyntaxError: invalid syntax.
I have no idea how to solve it.

Add a, it probably says where somewhere in the docs.

so I need to import os or re to rewrite the code from the package?

For some reason opencv doesn’t work on newer repls, you will have to fork an older repl that uses opencv. Try to fork this repl and paste your code in it:


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.