Page 1 of 1

Calling CloudCompare from Python

Posted: Thu Mar 01, 2018 12:36 pm
by alexs
I want to run CloudCompare in command-line mode from the Python program. CloudCompare installed at C:\CloudCompare. In Python I construct command command e.g.:

Code: Select all

C:\CloudCompare\CloudCompare.exe -SILENT -NO_TIMESTAMP -O lasfile.las -CROPD2D z 42 ....
and execute it with subprocess, like

Code: Select all

with subprocess.Popen(command,
                          shell=True,
                          stdout=subprocess.PIPE,
                          stdin=subprocess.DEVNULL,
                          stderr=subprocess.STDOUT,
                          universal_newlines=True) as proc:
# do something
But it does not work, instead a window pops-up with message
This application failed to start because it could not find or load the Qt platform plugin "windows" in "".

Available platform plugins are: direct2d, minimal, offscreen, windows, windows.

Reinstalling the application may fix this problem.
If I cd into C:\CloudCompare, open command line and execute the same command it works. Also same command works without errors when executed from the batch file.

I tried another approach: created batch file with required command and execute it using

Code: Select all

with subprocess.Popen("cmd.exe /c /path/to/batchfile.bat",
                          shell=True,
                          stdout=subprocess.PIPE,
                          stdin=subprocess.DEVNULL,
                          stderr=subprocess.STDOUT,
                          universal_newlines=True) as proc:
# do something
Still no luck, but error is different:
Syntax error in file name,directory name or drive letter
And again same batch file worked fine when executed directly or from command-line.

Am I doing something wrong? Any ideas how to make it work?