我使用python3 test.py在Ubuntu上运行python代码。然而,得到了以下错误:
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'似乎导入到web.py中的子进程找不到要调用的gsutil。
你知道怎么解决这个问题吗?我完全是个新手,任何提示都会有帮助!提前感谢!
更多详细信息:
test.py可以简化为:
from geowombat.util import GeoDownloads
path = xx
row = xx
gdl = GeoDownloads()
gdl.list_gcp('l5', f'{path:03d}/{row:03d}')我访问了errormsg中提到的web.py中的GeoDownloads.list_gcp(),它以subprocess.run(['gsutil', ...])的身份调用gsutil。但是,如果我将test.py更改为下面的代码片段,它就可以正常工作:
import subprocess
subprocess.run(["gsutil"])另外,我尝试将gsutil (/opt/anaconda3/bin/gsutil)的路径添加到path env中,错误将变为"NotADirectoryError: Not a directory: 'gsutil'“。
补充:/opt/anaconda3/bin已经存在于PATH env中。路径看起来像这样:/opt/anaconda3/bin:/opt/anaconda3/condabin:...
发布于 2021-07-06 04:32:55
好的,非常感谢@edemaine和@tdelaney。我再次尝试将/opt/anaconda3/bin添加到PATH中,它似乎通过了问题并继续前进。不知道为什么,似乎只能解析新添加的路径
https://stackoverflow.com/questions/68261517
复制相似问题