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.

3 Answers 3

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.

Sign up to request clarification or add additional context in comments.

3 Comments

Nope, unfortunately it produces same error. I gave absolute path of BCompare.exe
however, with subprocess.call('"C:\Users\BHD4ABT\Desktop\Beyond Compare 3\BCompare.exe') i am able to open beyond compare tool but cannot add files to compare
I modified above answer. Check That please.
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

Comments

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.