camelot-dev / camelot

A Python library to extract tabular data from PDFs
https://camelot-py.readthedocs.io
MIT License
2.85k stars 452 forks source link

No module named ghostscript #340

Open HepaxCodex opened 1 year ago

HepaxCodex commented 1 year ago

After following Camelot instructions (and a few other dead ends), python is unable to find ghostscript module.

Suggest:

  1. Adding a check during install if the ghostscript python api is installed.
  2. Updating instructions -and-/or install process if appropriate

Steps to reproduce the bug

Installation:

  1. brew update; brew upgrade; # Upgrade and update homebrew
  2. brew install ghostscript
  3. conda -v -n my_env -c conda-forge camelot-py
    • Note, this also appears to install anacondas ghostscript!

Steps to be used to reproduce behavior:

  1. python3 -c "from ctypes.util import find_library; print(find_library(\"gs\"))" # Outside of conda env
    /usr/local/lib/libgs.dylib@ -> ../Cellar/ghostscript/10.0.0/lib/libgs.dylib
  2. python3 -c "import ghostscript"
    Traceback (most recent call last):
    File "<string>", line 1, in <module>
    ModuleNotFoundError: No module named 'ghostscript'
  3. conda activate my_env
  4. python -c "from ctypes.util import find_library; print(find_library(\"gs\"))" # Per Camelot Docs
    /Users/<username>/opt/anaconda3/envs/finance/bin/../lib/libgs.dylib
  5. python -c "import ghostscript"
    Traceback (most recent call last):
    File "<string>", line 1, in <module>
    ModuleNotFoundError: No module named 'ghostscript'

Expected behavior

  1. ghostscript imports succesffully
  2. OR ... some sort of error is thrown during install to notify the user of missing deps

Code

import camelot
tables = camelot.read_pdf("./example.pdf")

Environment

Additional context

I have a development environment in conda with more deps, and also replicated with a fresh env, hopefully the dilineartion is clear in the environment specs.

unnikrishnancs commented 1 year ago

I am also facing the same issue. It's working fine on my local machine with Ububtu and Python 3.8. But I move my code to Centos server with Python 3.10, I get the "No module named ghostscript" error. Any fix for this ?

spaceemotion commented 1 year ago

I faced a similar issue and it looked like all I was missing was a pip install ghoscript. For some reason the wrapper did not get installed properly?

meta-ks commented 6 months ago

pip install ghoscript did solve the issue. Somehow it's not detecting the installed lib and the wrapper enables that.

jimhall commented 6 months ago

I encountered this issue back in 2020. See issue https://github.com/camelot-dev/camelot/issues/193. A lot of distributions (both OS and python, ex. Anaconda) would essentially only install the gs binary and not the associated libraries. IMHO this is not a Camelot issues, but more a Ghostscript install issue.

EduardoNeville commented 2 months ago

you have to install ghostscript: pip install ghostscript Both of these comments have a typo on the package name.

I faced a similar issue and it looked like all I was missing was a pip install ghoscript. For some reason the wrapper did not get installed properly?

pip install ghoscript did solve the issue. Somehow it's not detecting the installed lib and the wrapper enables that.