Trouble in importing openCV in python

this is the error that i am getting while trying to import open cv in replit.
the command i’m using - “import cv2 as cv”
the error -
Traceback (most recent call last):
File “main.py”, line 1, in
import cv2 as cv
File “/home/runner/UnfinishedSparseReciprocal/venv/lib/python3.10/site-packages/cv2/init.py”, line 181, in
bootstrap()
File “/home/runner/UnfinishedSparseReciprocal/venv/lib/python3.10/site-packages/cv2/init.py”, line 111, in bootstrap
load_first_config([‘config.py’], True)
File “/home/runner/UnfinishedSparseReciprocal/venv/lib/python3.10/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.

KeyboardInterrupt

I would be grateful for heling me out with this

I could be wrong, but this looks like an error in the module you’re importing - sometimes, just trying again later will work, they might just need a bit of time to fix it.

3 Likes

Hi @AdityaVarshney6 thanks for your question. Please see the post below for a link to a template which you can fork which works.

3 Likes

hello, thanks for your response, i tried to fork and run the replit that you provided -

but i got the following error -

Traceback (most recent call last):
File “/opt/virtualenvs/python3/lib/python3.8/site-packages/pytesseract/pytesseract.py”, line 255, in run_tesseract
proc = subprocess.Popen(cmd_args, **subprocess_args())
File “/usr/lib/python3.8/subprocess.py”, line 858, in init
self._execute_child(args, executable, preexec_fn, close_fds,
File “/usr/lib/python3.8/subprocess.py”, line 1704, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: ‘System_path_to_tesseract.exe’

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “main.py”, line 58, in
text = pytesseract.image_to_string(cropped)
File “/opt/virtualenvs/python3/lib/python3.8/site-packages/pytesseract/pytesseract.py”, line 423, in image_to_string
return {
File “/opt/virtualenvs/python3/lib/python3.8/site-packages/pytesseract/pytesseract.py”, line 426, in
Output.STRING: lambda: run_and_get_output(*args),
File “/opt/virtualenvs/python3/lib/python3.8/site-packages/pytesseract/pytesseract.py”, line 288, in run_and_get_output
run_tesseract(**kwargs)
File “/opt/virtualenvs/python3/lib/python3.8/site-packages/pytesseract/pytesseract.py”, line 260, in run_tesseract
raise TesseractNotFoundError()
pytesseract.pytesseract.TesseractNotFoundError: System_path_to_tesseract.exe is not installed or it’s not in your PATH. See README file for more information.

did I do something wrong?

Hi @AdityaVarshney6 no not at all.

The code in the Repl doesn’t work, but the forked version can be edited to run your program.

Hope this helps!

1 Like