Problem description:
I am unable to get opencv-python to work on REPL.it even though the packages are showing as installed. Receiving the following error:
File “/home/runner/OptimisticProudGenerics/venv/lib/python3.8/site-packages/cv2/init.py”, line 109, in load_first_config
raise ImportError(‘OpenCV loader: missing configuration file: {}. Check OpenCV installation.’.format(fnames))
ImportError: OpenCV loader: missing configuration file: [‘config.py’]. 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:
https://replit.com/@MarkFuller/OpenCV-Sketch-Example#main.py
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)
cv2.waitKey(0)
cv2.destroyAllWindows()
# 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)
cv2.waitKey(0)
cv2.destroyAllWindows()
Browser/OS/Device: