subprocess FileNotFoundError

  gsutil, popen, python, subprocess

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

File
"/opt/anaconda3/lib/python3.8/site-packages/geowombat/util/web.py",
line 1679, in list_gcp
        proc = subprocess.run(gsutil_str.split(' '),
      File "/opt/anaconda3/lib/python3.8/subprocess.py", line 489, in run
        with Popen(*popenargs, **kwargs) as process:
      File "/opt/anaconda3/lib/python3.8/subprocess.py", line 854, in __init__
        self._execute_child(args, executable, preexec_fn, close_fds,
      File "/opt/anaconda3/lib/python3.8/subprocess.py", 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 web.py 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:

test.py 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 web.py mentioned in errormsg, it’s calling gsutil as subprocess.run(['gsutil', ...]). However, if I change test.py to following snippet it works fine:

import subprocess
subprocess.run(["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

LEAVE A COMMENT