Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Google Cloud Function support/how-to? #324

Open
GavinBeattie opened this issue Jul 30, 2024 · 0 comments
Open

Google Cloud Function support/how-to? #324

GavinBeattie opened this issue Jul 30, 2024 · 0 comments

Comments

@GavinBeattie
Copy link

GavinBeattie commented Jul 30, 2024

I would like to use this library in a Google Cloud Function. A couple of issues:

  1. Is it possible to save the SVG to a BytesIO object, I tried but was unsuccessful. We don't have the option for local storage.
  2. graphviz.backend.execute.ExecutableNotFound: failed to execute 'dot', make sure the Graphviz executables are on your systems' PATH - Is there a way around this? ( I get similar error from Mac install).
    I noted it does work on Google Colab.

I suspect it's the sys.path between system and environment.

From GCF shell:
python -c import subprocess; proc = subprocess.Popen(['dot','-V'])
dot - graphviz version 2.43.0 (0)

From GCF Python 3.11:
proc = subprocess.Popen(['dot','-V'])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/layers/google.python.runtime/python/lib/python3.11/subprocess.py", line 1026, in init
self._execute_child(args, executable, preexec_fn, close_fds,
File "/layers/google.python.runtime/python/lib/python3.11/subprocess.py", line 1955, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'dot'

Local MacBook Pro (almost the same issue):

$ dot -V
dot - graphviz version 2.43.0 (0)

$ which dot
/usr/local/bin/dot

(Okay)
$ python3 -c "import subprocess; proc = subprocess.Popen(['dot','-V'])"
$ dot - graphviz version 12.0.0 (20240704.0754)

(Not okay)
From JupyterLab:
import subprocess
proc = subprocess.Popen(['dot','-V'])
FileNotFoundError: [Errno 2] No such file or directory: 'dot'

From Terminal
$ echo $PATH
...
/usr/local/bin
...

From JupyterLab:
import sys
sys.path
['/Users/gavinbeattie/Desktop/python-studio',
'/Users/gavinbeattie/anaconda3/lib/python311.zip',
'/Users/gavinbeattie/anaconda3/lib/python3.11',
'/Users/gavinbeattie/anaconda3/lib/python3.11/lib-dynload',
'',
'/Users/gavinbeattie/.local/lib/python3.11/site-packages',
'/Users/gavinbeattie/anaconda3/lib/python3.11/site-packages',
'/Users/gavinbeattie/anaconda3/lib/python3.11/site-packages/aeosa']

And
import os
print( os.getenv('PATH') )
/Users/gavinbeattie/anaconda3/bin
/Users/gavinbeattie/anaconda3/condabin
/usr/bin
/bin
/usr/sbin
/sbin

Where and how do I change/add /usr/local/bin/dot to enable it to work in Google Cloud Funtions/JupyterLab please?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant