我正在jupyter笔记本中使用python
我要执行以下命令:
$ gdalbuildvrt tmp_merge files
其中tmp_merge
是函数的输出文件,设置为:/home/prambaud/gfc_results/test/tmp_tile.vrt
和files
是设置为:/home/prambaud/gfc_results/test/tile_*.tif
的vrt
文件中要合并的所有分片
此函数授权使用通配符
要在我的Jupyter笔记本中运行它,我使用subprocess
模块:
command = [
'gdalbuildvrt',
'/home/prambaud/gfc_results/test/tmp_tile.vrt',
'/home/prambaud/gfc_results/test/tile_*.tif'
]
process = subprocess.run(
command,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
universal_newlines=True,
#cwd=os.path.expanduser('~')
)
print(process. stdout)
因此,我获得以下信息:
0...10...20...30...40...50...60...70...80...90...100 - done.
没有错误消息。但是没有创建输出文件。有人知道什么可以阻止subprocess.run
函数创建和写入文件吗
PS:
我还尝试使用!
从jupyter笔记本运行该命令,当然创建了相同的参数和tmp文件
我的命令只能从shell执行,因此使用subprocess我需要添加
shell
关键字,如下所示:相关问题 更多 >
编程相关推荐