camelot icon indicating copy to clipboard operation
camelot copied to clipboard

No module named 'cv2' when importing camelot

Open scotscotmcc opened this issue 3 years ago • 14 comments

I installed camelot via pip and then went to import it and the import failed, giving the error ModuleNotfoundError: No module named 'cv2'

I am on windows 10, python 3.10.2.

I was able to do a pip install opencv-python and once that completed, import of camelot worked fine. So I imagine that just opencv-python isn't properly identified as a dependency when install camelot via pip.

scotscotmcc avatar Mar 01 '22 16:03 scotscotmcc

I had the same error on MacOS and like you said installing opencv-python solved it for me too.

JoshuaDietz avatar Mar 07 '22 20:03 JoshuaDietz

I had this same issue, but when I looked into it it's because I didn't specify [base] in my pip command as specified in the readme: pip install camelot-python[base]

However, this was unexpected for me so I made a fix so that asking for either camelot-python or camelot-python[base] will result in usable packages.

@vinayak-mehta should I make a proper pull request? My fix is pretty minimal and backwards compatible, but it does move the install process in a different direction.

kuirolo avatar Mar 28 '22 19:03 kuirolo

@kuirolo just a note - I think you meant camelot-py in those examples above (vs -python)

mrshll avatar Apr 25 '22 20:04 mrshll

same issue of cv2 after trying to use camelot. I had a hard time specifying the base (python 3.10.2). The formatting that worked finally was pip install camelot-py 3. but still had the cv2 error afterwards. Is there a place to see which base are supported? I will try the pip install of opencv next.

treflip avatar May 11 '22 15:05 treflip

Same issue. Installed opencv-python, but now want's ghostsctipt :

File "/Users/xxxx/Documents/Projektit/PdfExtractEnergy/energy/lib/python3.8/site-packages/camelot/backends/ghostscript_backend.py", line 31, in convert
    raise OSError(

OSError: Ghostscript is not installed.

I have installed those wit brew in macbook m1

EDIT

  • [x] Tryed python 3.9 and now works. Have to do new clean virtal enviroment to test.

jhalmu avatar May 17 '22 16:05 jhalmu

I've encountered the same issue. However, even after installing 'opencv-python'.. the ModuleNotFoundError persists.

wangui-monicah avatar Jun 20 '22 15:06 wangui-monicah

I've encountered the same issue. However, even after installing 'opencv-python'.. the ModuleNotFoundError persists.

You have to downgrade to opencv-python==4.5.5.64. Try also to make a new clean virtual environment If it helps you follow the reading and comments from the issue i opened here

LuizMosciaro avatar Jun 22 '22 19:06 LuizMosciaro

Thanks folks. Based on your input above, this worked for me and may help others who appreciate the benefits of pipx:

$ pipx install camelot-py
$ pipx inject camelot-py opencv-python==4.5.5.64
$ pipx inject camelot-py ghostscript
$ camelot --help
Usage: camelot [OPTIONS] COMMAND [ARGS]...

  Camelot: PDF Table Extraction for Humans
...

nealmcb avatar Nov 09 '22 19:11 nealmcb