hklarner / pyboolnet

PyBoolNet is a Python package for the generation, modification and analysis of Boolean networks.
43 stars 21 forks source link

igraph2image functions fails #77

Closed valentin-noske closed 3 years ago

valentin-noske commented 3 years ago

I tried to use the igraph2image function but an error occured in the subprocess.py. This is was trying to do. `network = "models/mathmodel_1.bnet"

primes = read_bnet_file(network)

igraph = get_igraph(primes)

PyBoolNet.InteractionGraphs.igraph2image(igraph, "test.pdf", LayoutEngine="dot")`

And this is the error message I got from that.

PyBoolNet.InteractionGraphs.igraph2image(igraph, "test.pdf", LayoutEngine="dot") File "C:\Users\Valentin\Dropbox\Bachelorarbeit\Marker_Detection\venv2\lib\site-packages\pyboolnet-2.31.0-py3.8.egg\PyBoolNet\InteractionGraphs.py", line 214, in igraph2image PyBoolNet.Utility.DiGraphs.digraph2image(IGraph, FnameIMAGE, LayoutEngine=LayoutEngine, Silent=Silent) File "C:\Users\Valentin\Dropbox\Bachelorarbeit\Marker_Detection\venv2\lib\site-packages\pyboolnet-2.31.0-py3.8.egg\PyBoolNet\Utility\DiGraphs.py", line 248, in digraph2image proc = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) File "C:\Users\Valentin\AppData\Local\Programs\Python\Python38\lib\subprocess.py", line 854, in __init__ self._execute_child(args, executable, preexec_fn, close_fds, File "C:\Users\Valentin\AppData\Local\Programs\Python\Python38\lib\subprocess.py", line 1307, in _execute_child hp, ht, pid, tid = _winapi.CreateProcess(executable, args, FileNotFoundError: [WinError 2]Das System kann die angegebene Datei nicht finden

hklarner commented 3 years ago

well, looks like dot is probably not installed on your Windows machine. Did you install Graphviz on your machine?

valentin-noske commented 3 years ago

I have installed graphviz. Could it be that it cannot be found by my PyCharm virtual environment?

hklarner commented 3 years ago

I don't think it has to do with PyCharm or venv.

The path to you the executable of dot is in the settings.cfg file.

Try to run dot on your machine.

Also try PyBoolNet.InteractionGraphs.igraph2image(igraph, "test.pdf").

I am not a windows user.

This might help?

valentin-noske commented 3 years ago

Thank you. PyBoolNet.InteractionGraphs.igraph2image(igraph, "test.pdf") produces the same error. Therefore, I am not sure if dot is the problem.

valentin-noske commented 3 years ago

It looks like that this process _winapi.CreateProcess(executable, args..) leads to an error as executable is equal to None. The command that is tried to be executed is C:\Users\Valentin\Dropbox\Bachelorarbeit\Marker_Detection\venv2\lib\site-packages\pyboolnet-2.31.0-py3.8.egg\PyBoolNet\Dependencies\fdp -Tpdf -o test.pdf.

hklarner commented 3 years ago

fdp also belongs to Graphviz. Windows can't find the executable. Try running fdp or dot from the command line.

valentin-noske commented 3 years ago

This works!

hklarner commented 3 years ago

What happens if you edit the path to dot or fdp in

valentin-noske commented 3 years ago

Thanks. Yes, this worked. If I add the path of the program here (e.g dot = C:\Program Files\Graphviz\bin\dot), I dont have the problem anymore. I seems to be that pycharm is not using my Pathvariables.

hklarner commented 3 years ago

Ah, so it works even if you don't change the settings but run your script from the command line outside of PyCharm?

valentin-noske commented 3 years ago

No, I checked if that's the case but it is not. So I was wrong. But in pycharm it works now with the changes.

hklarner commented 3 years ago

Interesting. And great that it works now! :tada: