No module named 'cv2' when importing camelot
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.
I had the same error on MacOS and like you said installing opencv-python solved it for me too.
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 just a note - I think you meant camelot-py in those examples above (vs -python)
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.
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.
I've encountered the same issue. However, even after installing 'opencv-python'.. the ModuleNotFoundError persists.
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
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
...