Python ';diff pdf.exe';未被识别为内部或外部命令、可操作程序或批处理文件

Python ';diff pdf.exe';未被识别为内部或外部命令、可操作程序或批处理文件,python,pdf,Python,Pdf,我正在尝试使用diff pdf来比较2个pdf文件。下面是代码。我不断发现错误“diff pdf.exe”未被识别为内部或外部命令、可操作程序或批处理文件 import tkinter, sys import tkinter.filedialog programPath = "diff-pdf.exe" ## START GUI ## root = tkinter.Tk() # open and start tkinter object root.withdraw()

我正在尝试使用diff pdf来比较2个pdf文件。下面是代码。我不断发现错误“diff pdf.exe”未被识别为内部或外部命令、可操作程序或批处理文件

import tkinter, sys
import tkinter.filedialog 

programPath = "diff-pdf.exe" 

## START GUI ##
root = tkinter.Tk()         # open and start tkinter object
root.withdraw()             # hide the root window
## save sys.argv arguments (As file dialog changes it...) ##
optArgV = sys.argv[1:] # optional ArgV.

## ASK USER WHICH TWO FILES TO COMPARE ##
filePath1 = tkinter.filedialog.askopenfilename(title="Open First PDF - 1")
print ("pdf1: "+filePath1+"\n")  #Display first filepath
filePath2 = tkinter.filedialog.askopenfilename(title="Open Second PDF - 2")
print ("pdf1: "+filePath2+"\n")  #Display second filepath

## Run the command line instruction ##
from subprocess import check_output
if ( len(optArgV) > 0 ):   # pass though argument to diff-pdf.exe
print( "ARGUMENTS: "+" ".join(optArgV)+"\n" )
command = programPath+" "+" ".join(optArgV)+" \""+filePath1+"\" 
\""+filePath2+"\""
else:                       # Otherwise default to visual diff
command = programPath+" --view \""+filePath1+"\" \""+filePath2+"\""
print(">> "+command+"\n")
print( check_output( command , shell=True) )

input("Press Enter to continue...")

我想出来了。我的路径文件中没有“diff pdf.exe”。这是一个新手错误,我是Python新手。
谢谢,

因此在发送命令之前请打印出确切的命令,并查看
diff pdf.exe
是否位于该确切位置。看起来不是,这意味着您的命令路径不正确,或者您没有安装
diff pdf.exe
。我们不能从我们坐的地方检查这些东西。问题很可能是您没有在
程序路径
中指定目录,并且可执行文件所在的目录不在您的系统路径中(就像对带有此错误消息的所有其他问题的回答已经解释过一样)。我有“diff-pdf.exe”“在系统路径中。我已将.exe文件夹与python程序放在同一个文件夹中,但它仍然无法工作。我正在使用Python3.6,Ken White,也许我应该使用Python2?所以打开一个命令提示符,切换到脚本所在的确切文件夹,并从该提示符运行确切的命令行。从那里起作用吗?如果没有,它也无法从您的代码中工作。Python版本毫无意义;这不是Python的问题。这是配置问题。请复制并粘贴准确的错误消息。