When trying to run hello-world example
import sys
import ghostscriptargs = ["ps2pdf", # actual value doesn't matter"-dNOPAUSE", "-dBATCH", "-dSAFER","-sDEVICE=pdfwrite","-sOutputFile=" + sys.argv[1],"-c", ".setpdfwrite","-f", sys.argv[2]]ghostscript.Ghostscript(*args)
getting error:
File "/Users/ddd/sss/ddd/eee.py", line 2, in <module>import ghostscriptFile "build/bdist.macosx-10.6-universal/egg/ghostscript/__init__.py", line 33, in <module>File "build/bdist.macosx-10.6-universal/egg/ghostscript/_gsprint.py", line 290, in <module>
RuntimeError: Can not find Ghostscript library (libgs)
what is this libgs library and how can I get it?
btw I'm on mac
For newer user who are using M1 mac, ghostscript might show a missing libgs file error and the file would be unavailable at usr/local/lib
The issue can be resolved by following these steps, in the same order:
brew install ghostscript
conda install ghostscript
, which installs the arm_64 based library from conda-forge
- If conda throws a channel error try using
conda install -c conda-forge ghostscript
pip install ghostscript
Note:
- The libgs.dylib file can be found in the home brew installation of ghostscript
- Changing the address in
_gsprint.py
will throw an error as the brew installed version will be arm_64 based and the pip installed version will be OS_X86 based
- Python doesn't recognise ghostscript module from conda install unless pip install is run, so that is an essential step