Opencv-python installation error

Problem description:
I am unable to get opencv-python to work on even though the packages are showing as installed. Receiving the following error:
File “/home/runner/OptimisticProudGenerics/venv/lib/python3.8/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.

Note: From a previous thread, someone suggested using a very old project containing opencv-python. Forking that project caused the program to work correctly. Any newer projects though fail to work.
The forked project that worked by replacing the existing project code with my code is found at:
Working opencv-python when forked and code replaced

Expected behavior:
No configuration errors

Actual behavior:
Install/Configuration error for opencv-python module.

I have let the “import opencv-python” line perform the auto-install and I have also use the GUI package manager to deinstall/reinstall and also used pip in the terminal to deinstall/reinstall. All new projects freshly created fail.

Steps to reproduce:
Try using the opencv-python module

Bug appears at this link:

import cv2
import pathlib

# Step 0: Read Image from a file
file = pathlib.Path(__file__).parent.resolve() / input("Enter image name in same directory: ")
image1 = cv2.imread(str(file))

# Shows image on the screen until any button is pressed then closes windows
cv2.imshow('Hit any key to continue',image1)

# Step 1: Convert to Grey Image. Using cvtColor function of OpenCV. 
grey_img = cv2.cvtColor(image1, cv2.COLOR_BGR2GRAY)

# Step 2: Invert Image. 
invert = cv2.bitwise_not(grey_img)

# Step 3: Blur image.
blur = cv2.GaussianBlur(invert, (21, 21), 0)

# Step 4: Invert Blurred Image.
invertedblur = cv2.bitwise_not(blur)

# Step 5: Convert to Sketch. 
sketch = cv2.divide(grey_img, invertedblur, scale=256.0)

# Step 6: Save Sketch. Read back in to verify saved file
filesave = file.with_name(str(pathlib.Path(file).stem) + '-sketch.jpg')
cv2.imwrite(str(filesave), sketch)
image = cv2.imread(str(filesave))

# Step 7: Display sketch.
cv2.imshow('Hit any key to exit', image)


Hey @MarkFuller!

Can you try using our official OpenCV template to see if that works?

That template does not show up in the list when I create a new REPL. Forking it from where you gave it to my own REPL:

and attempting to run gives the following error(s) (More notes after bold output):

Enter image name in same directory: messi5.jpg
qt.qpa.plugin: Could not load the Qt platform plugin “xcb” in “/home/runner/Python-OpenCV-MARK/venv/lib/python3.8/site-packages/cv2/qt/plugins” even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: xcb.

SIGABRT: abort
PC=0x7fe9aa13fbaa m=0 sigcode=18446744073709551610
signal arrived during cgo execution

goroutine 1 [syscall, locked to thread]:
runtime.cgocall(0x4bb800, 0xc00006ccd8)
runtime/cgocall.go:156 +0x5c fp=0xc00006ccb0 sp=0xc00006cc78 pc=0x40651c
main._Cfunc_pry_eval_file(0x555556954c40, 0x55555697fb50, 0x1, 0x555556a0ea50)
_cgo_gotypes.go:562 +0x4c fp=0xc00006ccd8 sp=0xc00006ccb0 pc=0x4b944c
main.Python.EvalFile.func5(0x555556a0ea50, 0x8, {0xc00012e170, 0x0, 0x40ced5}, 0x0) +0x75 fp=0xc00006cd28 sp=0xc00006ccd8 pc=0x4ba455
main.Python.EvalFile({}, {0x7ffd61851eb4, 0x7}, {0xc00012e170, 0x0, 0x0}) +0x20c fp=0xc00006cde0 sp=0xc00006cd28 pc=0x4ba22c
main.(*Python).EvalFile(0x5d56d0, {0x7ffd61851eb4, 0x5d56d0}, {0xc00012e170, 0x0, 0xc00011d450})
:1 +0x45 fp=0xc00006ce18 sp=0xc00006cde0 pc=0x4bb265
[{{0x5075d0]({{0x5075d0), 0x5d56d0}, {0x7ffd61851e9e, 0xc0001180f0}}, {0x7ffd61851eb4, 0x7}, {0xc00012e170, 0x0, 0x0}) +0xa2 fp=0xc00006ce78 sp=0xc00006ce18 pc=0x4b8102
[{0x5075d0]({0x5075d0), 0x5d56d0}) +0x2e8 fp=0xc00006cf60 sp=0xc00006ce78 pc=0x4b89a8
main.main() +0x27 fp=0xc00006cf80 sp=0xc00006cf60 pc=0x4b8bc7
runtime/proc.go:255 +0x227 fp=0xc00006cfe0 sp=0xc00006cf80 pc=0x436d67
runtime/asm_amd64.s:1581 +0x1 fp=0xc00006cfe8 sp=0xc00006cfe0 pc=0x462e41

rax 0x0
rbx 0x6
rcx 0x7fe9aa13fbaa
rdx 0x0
rdi 0x2
rsi 0x7ffd6184ea20
rbp 0x7ffd6184ec60
rsp 0x7ffd6184ea98
r8 0x0
r9 0x7ffd6184ea20
r10 0x8
r11 0x246
r12 0x555556c669d8
r13 0x7ffd6184ee30
r14 0x7ffd6184edc8
r15 0x7ffd6184ee38
rip 0x7fe9aa13fbaa
rflags 0x246
cs 0x33
fs 0x0
gs 0x0
repl process died unexpectedly: exit status 2

I forked a previous project and it seemed to work based on a thread discussion. That older forked project was:

The above error message seems to indicate a dependency on PyQT. None of my local environments have PyQT installed as it has a cost to deploy using that module.
As far as I know, opencv-python should only rely on the TKinter that comes with Python. I do have PySide6 which is basically the same as PyQT but without a licensing requirement.


I think I remember having the same problem.

Ah, that’s not good! I’ll let the team know that this is an issue!

I have the same issue.

Earlier, I was able to use the opencv library but now I can’t use it :frowning: