Getting ghostscript to work with Python (camelot, OS X)¶
When you try to use the camelot Python library, you might get the error message Please make sure that Ghostscript is installed
even though ghostscript is installed! The camelot docs give some tips but they didn't work for me.
A solution that works¶
To solve this problem, we're going to create links from our ghostscript to the place camelot thinks ghostscript should be. We aren't moving it, we aren't copying it, we're just adding a little redirect that says "no, look for ghostscript in this other place!"
First, make sure you have ghostscript installed via homebrew.
After you install ghostscript (or if it's already installed), run the following command to find out what version of ghostscript you have.
Mine is listed as ghostscript 9.56.1. To create the link between the 9.56.1
location and the location camelot wants ghostscript to be in, you'll run the command below. If you have a different version you'll need to edit the command.
We're using the
sudo
command below, which asks for big powerful control over your computer. When it asks for your password, don't worry that you can't see what's being typed. It's working!
sudo mkdir -p /usr/local/lib
sudo ln -s /opt/homebrew/Cellar/ghostscript/9.56.1/lib/libgs.dylib.9.56 /usr/local/lib/libgs.9.dylib
sudo ln -s /opt/homebrew/Cellar/ghostscript/9.56.1/lib/libgs.dylib.9.56 /usr/local/lib/libgs.dylib
sudo ln -s /opt/homebrew/Cellar/ghostscript/9.56.1/lib/libgs.dylib.9.56 /usr/local/lib/libgs.dylib.9.56
And then you're good to go! Go forth and use .read_pdf
to read pdfs.
Answers that do not work¶
When reading through this GitHub thread I found a number of answers that didn't work!
First, this is how camelot tries to find ghostscript. Since it can't find it, it obviously doesn't work.
Then some people said hey, use distutils
, it can find ghostscript! Not for me, though.
And finally some people suggested adding library paths to your Jupyter notebook, which you do with %env
. That also didn't work!