Gnuplot error

If I may reopen this thread, I also have issues installing Gnuplot.jl but on a mac.
I do have gnuplot installed and it is in the path of mac terminal (bash):
image

Within Julia, I’ve added Gnuplot.jl and running test_terminal() returns:
IOError: could not spawn gnuplot --version: no such file or directory
Hence, I switch to Julia’s shell mode in order to check PATH:
image
Since export PATH=... does not seem to work, how to make gnuplot visible from within Julia?

I do not have much experience on the Mac, but the inability to work with PATH
seems to me to signal a problem with the terminal.

To check the path, don’t use the shell; rather, run ENV["PATH"] from the Julia prompt:

julia> ENV["PATH"]
"/usr/local/bin:/usr/bin[....]

You can test if Julia can run the gnuplot executable with

julia> s = run(`gnuplot --version`)
gnuplot 5.4 patchlevel 4
Process(`gnuplot --version`, ProcessExited(0))
1 Like

So gnuplot 5.4 handles the version correctly now?

Sorry Petr, I don’t understand the question; I think I’m missing some context. Was there a problem with some version of gnuplot in the past?

(I’m using Linux; but the two commands I showed above should run on Mac too AFAIK).

Thanks! But how to edit PATH? I would like to add /opt/local/bin/ to it, then it would find gnuplot. PATH is supposed to be a shell variable but I do not manage to change it in shell mode. I also do not manage to figure out which type of shell (bash, zsh…) shell mode is actually using.

:+1:

I can’t confirm since I’m not on Windows, but it is marked as resolved in gnuplot’s issue tracker.

I think Julia uses its own shell. You can set the PATH from within Julia with

ENV["PATH"] = "$(ENV["PATH"]):/opt/local/bin"

I’ve never used a Mac, but an alternative might be to invoke Julia from a command line as

$ export PATH+=:/opt/local/bin
$ julia
1 Like

Oh, I think I was not clear :smiley: /opt/local/bin is already in my PATH when I use the terminal. This is why I can use gnuplot from the command line.
My problem is that it is not in the PATH when using Julia. Therefore I try to edit PATH within Julia (using the Julia shell for example).

Have you tried invoking Julia from the same terminal? If you run it by double-clicking an icon, it may be running with a different environment. Normally, Julia should just inherit the PATH from the terminal you run it from.

Oh yes, indeed when julia is called from the terminal it does inherit the PATH variable. Thanks.
My issue was that I was running it from VScode, there the inherited PATH is different.
This line solved my issue:

ENV["PATH"] = "$(ENV["PATH"]):/opt/local/bin"

I will add it to my startup file. Thanks again these gnuplot figures look so nice… :smiley:

1 Like