If I execute this script in windows with x86 Python, works just fine. Also from command line directly.
import os, subprocess
gm = os.path.join('C:\\', 'Program Files (x86)', 'GDAL', 'gdal_merge.py')
merge_command = ["python", gm, "-o", "C:\\temp\\merge2.asc", "C:\\temp\507円.asc", "C:\\temp\508円.asc"]
subprocess.call(merge_command, shell=True)
However, in another machine, with windows and python x64, command line tool works, but the python script does not (it only differs from the previous one in the program files directory where gdal_merge.py is located).
import os, subprocess
gm = os.path.join('C:\\', 'Program Files', 'GDAL', 'gdal_merge.py')
merge_command = ["python", gm, "-o", "C:\\temp\\merge2.asc", "C:\\temp\507円.asc", "C:\\temp\508円.asc"]
subprocess.call(merge_command, shell=True)
What could be happening? Can anyone help?
-
What's the error? Note that gdal_edit.py is written in such a way that you could import it directly from your script, then call it's main() function with the arguments.mikewatt– mikewatt2018年07月27日 19:47:00 +00:00Commented Jul 27, 2018 at 19:47
-
Actually, it doesnt't show any error, it seems to process fine, but not operation is actually done. I tried importing gdal_merge, but it says I have no module named as such (I have installed Python, GDAL and GDAL python bindings)Oskar Karlsson– Oskar Karlsson2018年07月27日 19:49:28 +00:00Commented Jul 27, 2018 at 19:49
-
Maybe try subprocess.check_call() or subprocess.check_output()mikewatt– mikewatt2018年07月27日 19:51:16 +00:00Commented Jul 27, 2018 at 19:51
-
Apparently I get some error or non-zero exit code. subprocess.check_call(merge_command, shell=True) Traceback (most recent call last): File "<interactive input>", line 1, in <module> File "C:\Python27\lib\subprocess.py", line 190, in check_call raise CalledProcessError(retcode, cmd) CalledProcessError: Command '['python', 'C:\\Program Files\\GDAL\\gdal_merge.py', '-o', 'C:\\temp\\merge2.asc', 'C:\\temp\507円.asc', 'C:\\temp\508円.asc']' returned non-zero exit status 1Oskar Karlsson– Oskar Karlsson2018年07月27日 22:26:11 +00:00Commented Jul 27, 2018 at 22:26
1 Answer 1
I was able to make it work under python 32 bits, while in 64 bits, with their respective GDALs, it didnt work. May be some bug, I guess.