Opencv Errror even though installed

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.

any suggestions?

My test code looks like the following:

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)

Welcome to the community! I’m not familiar with this particular Python module but it appears that your installation of it may be corrupted. Try the following:
In shell, run poetry remove cv2; poetry add cv2.
If that doesn’t work, try pip install cv2.

1 Like

CoderElijah, Thank you for your suggestion. I have already done those things, both in the terminal and using the GUI package manager, as well as letting the template auto-install upon seeing the “import opencv-python” line in the code.

I did find an old thread that has a working solution, but it still needs addressing by the REPL team. If I fork a very old project with opencv, the fork will work. Any project created with recent templates fails.

Would you mind including the link to that thread since it solved your problem?

Sorry for me not being a big help but welcome to replit ask @MarkFuller. Hope you enjoy your time with us.

It will take me a while to find the discussion thread as I don’t have that handy. The discussion said to fork the following REPL that was an opencv example.

If I fork that REPL, delete all the code, and then paste all of my code inside, it works correctly.
If I start a new REPL it fails with an opencv configuration error.
I have let the “import opencv” auto install, but errors…
I have used GUI package manager to remove and reinstall opencv-python but it errors.

The only working solution has been to fork that old project, and hope that the old project never disappears.

I have used terminal and “pip install opencv-python” but still errors

For anyone else encountering this issue, you could try downgrading OpenCV version:

pip install opencv-python==

If the OpenCV package gets forecfully updated during installation of other packages, you can simply re-run the pip install command above.

1 Like

I’m bumping this topic, because I tried this last year and I find that it still has the same error as before. Something about a configuration file problem. This would be a good thing to fix, because opencv is an important library.

1 Like

Hey, @MarkFuller @dniemitalo !

Running OpenCV requires some extra configuration. Because of this, the staff have released a template that has everything configured and OpenCV installed here:


Thanks; this is good to know. Now I can play with opencv.

This doesn’t appear in the template list when I create a new repli, although I see that there is a Java opencv template in there. Is there some listing of useful templates like this that don’t appear in the menu, or some other way that people would know about this type of thing?

1 Like

Hi @dniemitalo !
This not available at the moment, bit you can suggest it by making a post under Feature Requests .

Some templates may only appear on the template page, however it doesn’t seem to be listed there, templates are supposed to be reviewed before they are added so the staff likely just haven’t got around to, essentially, ‘whitelisting’ it yet. :smile:



If I’m importing a repo from Github that has the OpenCV package, would forking this old repl work for me?

I want to be able to push into the imported repo, so I have to be connected to it somehow, and I can’t select the OpenCV template as it’s not official.

@DanielBelfort Isuppose it would work, yes.

I mean: how would I be able to contribute and connect to an existing repo and fork the old repl (that has OpenCV correctly configured)?

You can fork the repl for OpenCV above, then connect the repo with the Git tool, and push changes whenever you want.

The Git tool only let’s me initialize a repo when I fork the repl, not “connect” to an existing one… (?)

Hmm… what if you manually pushed changes using commands?

What do you mean by this?

Do you have a GH account connected at Could you try disconnecting and reconnecting it?