subprocess FileNotFoundError

  gsutil, popen, python, subprocess

I’m running python code on Ubuntu with python3 However got following error:

line 1679, in list_gcp
        proc =' '),
      File "/opt/anaconda3/lib/python3.8/", line 489, in run
        with Popen(*popenargs, **kwargs) as process:
      File "/opt/anaconda3/lib/python3.8/", line 854, in __init__
        self._execute_child(args, executable, preexec_fn, close_fds,
      File "/opt/anaconda3/lib/python3.8/", line 1702, in _execute_child
        raise child_exception_type(errno_num, err_msg, err_filename)
    FileNotFoundError: [Errno 2] No such file or directory: 'gsutil'

It seems that subprocess imported in cannot find gsutil to call.

Any idea how to solve this? I’m totally new to these, any hint helps! Thanks in advance!

More details: can be simplified as following:

from geowombat.util import GeoDownloads
path = xx
row = xx
gdl = GeoDownloads()
gdl.list_gcp('l5', f'{path:03d}/{row:03d}')

And I went to GeoDownloads.list_gcp() in mentioned in errormsg, it’s calling gsutil as['gsutil', ...]). However, if I change to following snippet it works fine:

import subprocess["gsutil"])

Additionally, I tried adding path of gsutil (/opt/anaconda3/bin/gsutil) to PATH env, the error will change to "NotADirectoryError: Not a directory: 'gsutil'".

Source: Python Questions