camelot icon indicating copy to clipboard operation
camelot copied to clipboard

No module named ghostscript

Open HepaxCodex opened this issue 3 years ago • 5 comments

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
  1. python3 -c "import ghostscript"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'ghostscript'
  1. conda activate my_env
  2. 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
  1. 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

  • OS: macOS 12.4
    • uname -a
    • Darwin mylappy.local 21.5.0 Darwin Kernel Version 21.5.0: Tue Apr 26 21:08:22 PDT 2022; root:xnu-8020.121.3~4/RELEASE_X86_64 x86_64
  • Python version (Conda complete dev env): 3.9.15
  • Python version (Conda standalone env): 3.11.0
  • Python version (System): 3.10.9
  • Numpy version (Conda complete dev env): 1.24.0
  • Numpy version (Conda standalone env): 1.24.1
  • OpenCV version (Conda, both envs): 4.6.0
  • Ghostscript version (Conda, both envs): 9.54
  • Ghostscript version (System): 10.0
  • Camelot version (Conda, both envs): 0.10.1

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.

HepaxCodex avatar Dec 30 '22 23:12 HepaxCodex

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 ?

unnikrishnancs avatar May 25 '23 12:05 unnikrishnancs

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?

spaceemotion avatar Jun 10 '23 21:06 spaceemotion

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

meta-ks avatar Feb 01 '24 11:02 meta-ks

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.

jimhall avatar Feb 01 '24 13:02 jimhall