No module named ghostscript
After following Camelot instructions (and a few other dead ends), python is unable to find ghostscript module.
Suggest:
- Adding a check during install if the ghostscript python api is installed.
- Updating instructions -and-/or install process if appropriate
Steps to reproduce the bug
Installation:
brew update; brew upgrade; # Upgrade and update homebrewbrew install ghostscriptconda -v -n my_env -c conda-forge camelot-py- Note, this also appears to install anacondas ghostscript!
Steps to be used to reproduce behavior:
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
python3 -c "import ghostscript"
Traceback (most recent call last):
File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'ghostscript'
conda activate my_envpython -c "from ctypes.util import find_library; print(find_library(\"gs\"))" # Per Camelot Docs
/Users/<username>/opt/anaconda3/envs/finance/bin/../lib/libgs.dylib
python -c "import ghostscript"
Traceback (most recent call last):
File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'ghostscript'
Expected behavior
- ghostscript imports succesffully
- 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 -aDarwin 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.
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 ?
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.
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.