RustGnuplot icon indicating copy to clipboard operation
RustGnuplot copied to clipboard

Couldn't spawn gnuplot. Make sure it is installed and available in PATH

Open hasanAjsf opened this issue 4 years ago • 3 comments

While running the example:

// This file is released into Public Domain.
use gnuplot::*;
use std::f32;

fn main()
{
	let mut fg = Figure::new();
	let mut x = vec![];
	for i in 0..100i32
	{
		x.push(i as f32 * 0.1 - 5.0);
	}

	let mut t = 0.0;
	fg.set_terminal("gif animate optimize delay 2 size 480,360", "fg.gif.gif");
	for i in 0..100
	{
		if i > 0
		{
			fg.new_page();
		}
		let ax = fg.axes2d().set_y_range(Fix(-1.0), Fix(1.0));
		ax.lines(
			x.iter(),
			x.iter()
				.map(|&x| (x + t as f32 * 0.1 * 2. * f32::consts::PI).sin()),
			&[Color("blue")],
		);
		ax.lines(
			x.iter(),
			x.iter()
				.map(|&x| (x + t as f32 * 0.1 * 2. * f32::consts::PI).cos()),
			&[Color("red")],
		);
		t += 0.1;
	}
	fg.echo_to_file("fg.gif.gnuplot");
	fg.show();
}

I got the error:

    Finished dev [unoptimized + debuginfo] target(s) in 0.20s
     Running `target\debug\rust.exe`
thread 'main' panicked at 'Couldn't spawn gnuplot. Make sure it is installed and available in PATH.: Os { code: 2, kind: NotFound, message: "The system cannot find the file specified." }', src\libcore\result.rs:1165:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
error: process didn't exit successfully: `target\debug\rust.exe` (exit code: 101)

Knowing that I've gnuplot and it is installed in my Win 10 machine, and added to the path:

image

hasanAjsf avatar Sep 10 '19 19:09 hasanAjsf

It failed because it tries to execute the command gnuplot --version, and could not find gnuplot in your path. Can you please try to execute that same command by hand ?

fodil-a avatar Sep 18 '19 19:09 fodil-a

@fodil-a

It gave:

PS C:\Users\hasan.DESKTOP-HU2FQ29> gnuplot --version
gnuplot 5.2 patchlevel 7

hasanAjsf avatar Sep 21 '19 16:09 hasanAjsf

You also need to make sure the rust process (and the library) have the updated PATH environment when trying to call gnuplot. Restarting the computer would do the trick. (I guess it has been been done long ago already, so if gnuplot is still installed, it should just work.)

vn971 avatar Jan 09 '20 13:01 vn971