0

I am making use of Beyond Compare 3 to see the difference between two XML files. I am willing to make a small python script which on executing will open files ready to compare in Beyond Compare tool.

So far I tried invoking BC3 from command line syntax as below and it works:

BCompare.exe "c:\Ref-2.xml"  "c:\Cop-2.xml"

but when I try to execute same syntax from python script as shown below, It throws error

from subprocess import check_output
check_output('BCompare.exe "c:\Ref-2.xml"  "c:\Cop-2.xml"', shell=True)

The error which is shown is:

raise CalledProcessError(retcode, cmd, output=output)
subprocess.CalledProcessError: Command 'BCompare.exe "c:\Ref-2.xml"  "c:\Cop-2.xml"' returned non-zero exit status 1

am I missing something? I tried different solutions to open command line instructions using this tutorial and many others but its not working.

Community
  • 1
  • 1
Radheya
  • 779
  • 1
  • 11
  • 41

3 Answers3

1

Do something like this. Give Absolute path of .exe

check_output(absolute_path_of_beyond_compare "c:\Ref-2.xml"  "c:\Cop-2.xml"', shell=True)

I am able to open the Beyond Compare using following code:

from subprocess import check_output

check_output("BCompare.exe Test1.txt Test2.txt", shell=True)

where BCompare.exe path is added in path variable and Test1.txt Test2.txt are present in the same directory from where i have executed the program.

BigBang
  • 149
  • 12
1
import subprocess
subprocess.Popen([r"C:\Program Files\Beyond Compare 4\BCompare.exe", r"FullFilePath_File1", r"FullFilePath_File2"])

I tested on mine, and it works. Instead of checkout, I am using Popen. I am using Jupyter notebook by installing Anaconda3-5.2.0-Windows-x86_64

Python version = 3.6.5

S Raghav
  • 1,386
  • 1
  • 16
  • 26
AL TI
  • 11
  • 1
0

use exact path where the beyond compare is installed or add that to your environment variable "Path". in case using exact path of installation put something line "\"C:\Program Files\Beyond Compare 4\BCompare.exe\" test1.txt test2.txt" the \" enables to read the special characters and extra spaces in path