Need to install Ghostscript to Mac PATH
Asked Answered
C

2

5

Getting an error with Camelot, "Ghostscript is not installed".

Tried everything, the issue is that it is not added to path, gs IS installed on the machine.

Failing the following check from Camelot install page https://camelot-py.readthedocs.io/en/master/user/install-deps.html...

For Ghostscript Open the Python REPL and run the following:

For Ubuntu/MacOS:

from ctypes.util import find_library
find_library("gs")
"libgs.so.9"

Check: The output of the find_library function should not be empty.

If the output is empty, then it’s possible that the Ghostscript library is not available one of the LD_LIBRARY_PATH/DYLD_LIBRARY_PATH/PATH variables depending on your operating system. In this case, you may have to modify one of those path variables.

...

The output is returning empty.

So that is the issue, needs to be added to these paths, I have no idea how to do it.

Step by step instructions would be fantastic.

as above as above as

Chickpea answered 8/2, 2023 at 21:14 Comment(2)
Does this answer your question? How to set the environmental variable LD_LIBRARY_PATH in linuxYogurt
raises more questions for me unfortunately... I tried alot of the answers there and still no joyChickpea
F
9

This guy here has a different (beautiful) solution that works for me on a Mac M1 machine. Looks like the proposed solution is OS agnostic.

In summary, Camelot relies on Ghostscript and uses ctypes.util.find_library('gs') to locate it. The find_library function looks for specific filenames and paths, including "~/lib" among others.

The solution is then to simply link Ghostscript to a newly created "~/lib" directory where find_library looks for it.

# Create a "lib" folder in your user directory: 
mkdir -p ~/lib

# Link Ghostscript to the "lib" folder: 
ln -s "$(brew --prefix gs)/lib/libgs.dylib" ~/lib

DYLD_FALLBACK_LIBRARY_PATH usually doesn't work, especially on newer macOS versions with SIP (System Integrity Protection) enabled.

Fertile answered 27/9, 2023 at 8:5 Comment(1)
what worked for me is: I replace $(brew --prefix gs) with absolute path till lib found via command find /usr /opt -name "libgs.dylib" So, my final command looks like: ln -s "/opt/homebrew/Cellar/ghostscript/10.02.0/lib/libgs.dylib" ~/lib After that if you get error Ghostscript module not found, just do pip install ghostscript.Engel
J
0

I don't know that package that you are using, nor do I know how you installed ghostscript so we'll have to go from first principles.

You need to:

  • find libgs.dylib, then
  • tell your tools where it is by setting DYLD_LIBRARY_PATH

You should be able to find the ghostscript library with this command:

find /usr /opt -name "libgs.dylib"

If that doesn't find it, try harder with:

find /usr /opt -name "libgs.dylib.*"

And if that doesn't find it, try even harder with:

find / -name "libgs.dylib.*" 2> /dev/null

Once you have found it, it might look something like:

/opt/homebrew/bin/libgs.dylib

Now you need to strip off everything from the rightmost slash onwards. In this example that leaves:

/opt/homebrew/bin

Now you need to add that to your path like this:

export DYLD_LIBRARY_PATH=DYLD_LIBRARY_PATH:/opt/homebrew/bin

Then run the Python REPL stuff per your original instructions.

Jeanne answered 8/2, 2023 at 22:56 Comment(8)
Thanks for your response. I am setting this PATH using; sudo nano ~/.bash_profile is this the correct place to set this path? it is not working for meChickpea
No, that's not correct at all. I didn't mention either sudo or ~/.bash_profile or PATH.Jeanne
Oh ok... regardless, I actually managed to set the path, by setting the path in ~/.bashrc, and then using source ~/.bashrc .... managed to get a response to the above check. Unfortunately I am still getting the same "ghostscript not installed" error from camelot, even after reinstalling camelot and rebooting the machineChickpea
Did you run the find command I suggested? What did you find as a result? Then what did you do with the result?Jeanne
Yeah and I found the path. As above, I successfully added the path, getting an output to the test. Camelot is still throwing an error, "Ghostscript is not installed"Chickpea
Ok, now you need to find where your ghostscript is installed so run ls -l /opt/homebrew/bin/gs to see if it is there. If it is, do export PATH=$PATH:/opt/homebrew/bin and try Camelot again.Jeanne
Did you manage to sort this @Chickpea ? I have the same issue, I've done all the steps and still no luck..Hanoverian
chilifan -- please check my comment in the other answer, after spending hours, I was able to fix on mac os 14.0, m2 siliconEngel

© 2022 - 2024 — McMap. All rights reserved.