Is Graphviz supported on Replit?

getting an error from running the simple code below in Replit.
is graphviz not supported?

from graphviz import Digraph

dot = Digraph(‘AI_Development_Scenarios’)
dot.attr(rankdir=‘LR’)

dot.node(‘A’, ‘AI Development’)
dot.node(‘B’, ‘Normal Tech’)
dot.node(‘C’, ‘Slow Takeoff’)
dot.node(‘D’, ‘Fast Takeoff’)
dot.node(‘E’, ‘Aligned’)
dot.node(‘F’, ‘Misaligned’)
dot.node(‘G’, ‘Aligned’)
dot.node(‘H’, ‘Misaligned’)

dot.edges([‘AB’, ‘AC’, ‘AD’, ‘CE’, ‘CF’, ‘DG’, ‘DH’])
dot.view()

2 Likes

I’ve used the CLI in the past in a repl, so you could probably make it work correctly. Could you give an example repl?

1 Like

hey thanks, sorry I’m new here, how do I give an example repl? just link?

1 Like

Sure! As far as I know, there isn’t a better way to share a repl. Just make sure you don’t share an invite URL.

I can only find the Invite URL, searching how to share a simple link that is not an invite.

from graphviz import Digraph

dot = Digraph('AI_Development_Scenarios')
dot.attr(rankdir='LR')

dot.node('A', 'AI Development')
dot.node('B', 'Normal Tech')
dot.node('C', 'Slow Takeoff')
dot.node('D', 'Fast Takeoff')
dot.node('E', 'Aligned')
dot.node('F', 'Misaligned')
dot.node('G', 'Aligned')
dot.node('H', 'Misaligned')

dot.edges(['AB', 'AC', 'AD', 'CE', 'CF', 'DG', 'DH'])
dot.view()

also trying to format my code, it’s really short

1 Like

Link to your repl will look like this: https://replit.com/@yourusername/yourreplname
Also, wrap your code in triple backticks (```) for it to be formatted.
EX:
```
print(“Hello world!”)
```
Is

print("Hello world!")

(trying to figure out how to format code so it looks like code)

```;
from graphviz import Digraph

dot = Digraph('AI_Development_Scenarios')
dot.attr(rankdir='LR')

dot.node('A', 'AI Development')
dot.node('B', 'Normal Tech')
dot.node('C', 'Slow Takeoff')
dot.node('D', 'Fast Takeoff')
dot.node('E', 'Aligned')
dot.node('F', 'Misaligned')
dot.node('G', 'Aligned')
dot.node('H', 'Misaligned')

dot.edges(['AB', 'AC', 'AD', 'CE', 'CF', 'DG', 'DH'])
dot.view()
```;
2 Likes

Try removing the semicolons after the 3 backticks.

1 Like

As others have already said:

Hello @jelaludo! Please edit your post’s code to be formatted like this:

```python
Your code here
```

So that it is easier for staff and members of the community to help you with your issue!

PS: if you cannot edit your post, please read around a little to increase your trust level and let you access editing your posts.

Also see this guide on how to share your code:

main.py - AIscenarios - Replit

thanks for your patience and help ^^

(trying to figure out how to format code so it looks like code. part3)

```
from graphviz import Digraph

dot = Digraph('AI_Development_Scenarios')
dot.attr(rankdir='LR')

dot.node('A', 'AI Development')
dot.node('B', 'Normal Tech')
dot.node('C', 'Slow Takeoff')
dot.node('D', 'Fast Takeoff')
dot.node('E', 'Aligned')
dot.node('F', 'Misaligned')
dot.node('G', 'Aligned')
dot.node('H', 'Misaligned')

dot.edges(['AB', 'AC', 'AD', 'CE', 'CF', 'DG', 'DH'])
dot.view()
```

Why is your code wrapped in a <pre> element? Try not wrapping it in one.

indeed, I don’t have the right to edit yet… gotta be earned ^^

main.py - AIscenarios - Replit

thanks for your patience and help ^^

(trying to figure out how to format code so it looks like code. part4)

from graphviz import Digraph

dot = Digraph('AI_Development_Scenarios')
dot.attr(rankdir='LR')

dot.node('A', 'AI Development')
dot.node('B', 'Normal Tech')
dot.node('C', 'Slow Takeoff')
dot.node('D', 'Fast Takeoff')
dot.node('E', 'Aligned')
dot.node('F', 'Misaligned')
dot.node('G', 'Aligned')
dot.node('H', 'Misaligned')

dot.edges(['AB', 'AC', 'AD', 'CE', 'CF', 'DG', 'DH'])
dot.view()
1 Like

Try adding pkgs.graphviz to your replit.nix file.

Can you provide the error you received when running the repl?

ok so graphviz is not supported since it’s meant to be run as an administrator on a jupytor notebook or anaconda on your local device and thus it needs admin exec rights (for rendering) otherwise it’ll work if you don’t render

It should work if it’s installed using nix (I’ve used it in the past)

2 Likes

oh ok but idk it works other than rendering

because I was following ChatGPT4’s instruction on how to format text on replit… not that reliable yet, hey

1 Like

Traceback (most recent call last):
File “/home/runner/AIscenarios/venv/lib/python3.10/site-packages/graphviz/backend/execute.py”, line 81, in run_check
proc = subprocess.run(cmd, **kwargs)
File “/nix/store/hd4cc9rh83j291r5539hkf6qd8lgiikb-python3-3.10.8/lib/python3.10/subprocess.py”, line 503, in run
with Popen(*popenargs, **kwargs) as process:
File “/nix/store/hd4cc9rh83j291r5539hkf6qd8lgiikb-python3-3.10.8/lib/python3.10/subprocess.py”, line 971, in init
self._execute_child(args, executable, preexec_fn, close_fds,
File “/nix/store/hd4cc9rh83j291r5539hkf6qd8lgiikb-python3-3.10.8/lib/python3.10/subprocess.py”, line 1847, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: PosixPath(‘dot’)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File “main.py”, line 16, in
dot.view()
File “/home/runner/AIscenarios/venv/lib/python3.10/site-packages/graphviz/_tools.py”, line 171, in wrapper
return func(*args, **kwargs)
File “/home/runner/AIscenarios/venv/lib/python3.10/site-packages/graphviz/rendering.py”, line 185, in view
return self.render(filename=filename, directory=directory, view=True,
File “/home/runner/AIscenarios/venv/lib/python3.10/site-packages/graphviz/_tools.py”, line 171, in wrapper
return func(*args, **kwargs)
File “/home/runner/AIscenarios/venv/lib/python3.10/site-packages/graphviz/rendering.py”, line 122, in render
rendered = self._render(*args, **kwargs)
File “/home/runner/AIscenarios/venv/lib/python3.10/site-packages/graphviz/_tools.py”, line 171, in wrapper
return func(*args, **kwargs)
File “/home/runner/AIscenarios/venv/lib/python3.10/site-packages/graphviz/backend/rendering.py”, line 324, in render
execute.run_check(cmd,
File “/home/runner/AIscenarios/venv/lib/python3.10/site-packages/graphviz/backend/execute.py”, line 84, in run_check
raise ExecutableNotFound(cmd) from e
graphviz.backend.execute.ExecutableNotFound: failed to execute PosixPath(‘dot’), make sure the Graphviz executables are on your systems’ PATH

I would not ask Chat-GPT, it is know for having human-like conversation, but also known for spitting misinformation left and right

2 Likes