fpom / snakes

SNAKES is the Net Algebra Kit for Editors and Simulators
https://snakes.ibisc.univ-evry.fr
Other
89 stars 29 forks source link

snakes.plugins.gv | PetriNet.draw error #10

Closed rafascar closed 8 years ago

rafascar commented 8 years ago

Hello,

I'm trying to draw my petri net using the Module snakes.plugins.gv but I'm running into this error everytime I try to call the method PetriNet.draw.

Traceback (most recent call last):
  File "C:/.../arc-annotations.py", line 21, in <module>
    net.draw('value-0.png')
  File "C:\Python27\lib\site-packages\snakes\plugins\gv.py", line 239, in draw
    g.render(filename, engine, debug)
  File "C:\Python27\lib\site-packages\snakes\plugins\gv.py", line 139, in render
    stderr=subprocess.STDOUT)
  File "C:\Python27\lib\subprocess.py", line 710, in __init__
    errread, errwrite)
  File "C:\Python27\lib\subprocess.py", line 958, in _execute_child
    startupinfo)
WindowsError: [Error 2] The system cannot find the file specified

To write the code I followed this example.

I've already searched and tried to fix it but no success. Any ideas?

himito commented 8 years ago

Hi !,

Do you have 'dot' executable in your PATH? Do you execute the script from the command line ?

rafascar commented 8 years ago

Hi @himito, thanks for your reply!

What do you mean by 'dot executable'?

I added C:\Python27\Lib\site-packages\graphviz\dot.py to my PATH and tried to run from the command line too but no success.

EDIT: I had only installed the graphviz python package, not on Windows. Now I've installed for windows and added the dot.exe to my PATH, but no changes.

himito commented 8 years ago

I mean http://www.graphviz.org/Download_windows.php :)

Note: As of version 2.31, the Visual Studio package no longer alters the PATH variable or accesses the registry at all. If you wish to use the command-line interface to Graphviz or are using some other program that calls a Graphviz program, you will need to set the PATH variable yourself.

Also, you could try to define the absolute path for value-0.png. Could you share your py file ?.

rafascar commented 8 years ago

I installed GraphViz 2.38 and added the %programfiles(x86)%\Graphviz2.38\bin\dot.exe; to my PATH, as well as creating a new environment variable GRAPHVIZ_DOT with the path as it is described here, but the error persisted :(

Here is the code I'm trying to run:

import snakes.plugins
snakes.plugins.load("gv", "snakes.nets", "nets")
from nets import *

def factory(cons, prod, init=[1, 2, 3]):
    n = PetriNet("N")

    n.add_place(Place('src', init))
    n.add_place(Place('tgt', []))
    t = Transition('t')
    n.add_transition(t)

    n.add_input('src', 't', cons)
    n.add_output('tgt', 't', prod)

    return n, t, t.modes()

net, trans, modes = factory(Variable('x'), Variable('x'))
net.draw('value-0.png', engine='dot')

Thank you!

EDIT: So I added C:\Program Files (x86)\Graphviz2.38\bin to my PATH and now it works. Lol. Rookie mistake. Thank you @himito!

himito commented 8 years ago

You are welcome :D @rafascar

fpom commented 8 years ago

Many thanks @himito for your help! I'm currently having holidays and I'm far away from a computer. I'm happy it works now! :-)

wespe commented 8 years ago

Thank you, guys!

fkgl commented 4 years ago

Hi, please, I'm using python 3.8 with Pycharm IDE 2020.1.1 , I'm trying to use snakes but I can't load plugins (snakes.plugins.load("gv", "snakes.nets", "nets") from nets import *) if I pass the mouse on the load the message (You need configured Python 2 SDK to render Epydoc docstrings) is displayed. I don't know if that is the problem or there is another problem I try to install epydoc but the problem is not resolved; please can someone help me?