python ghostscript Popen 无法找到文件
import ghostscript
import sys, subprocess,os
output = subprocess.Popen(['gs', '-dSAFER', '-dNOPAUSE', '-dBATCH', '-sDEVICE=tiffg4', '-g6120x7920 ','-r720x720','-sOutputFile=C:\Python25\pdfmining\page_%03d.tif' 'C:\Python25\pdfmining\ae.pdf'])
出现了一个错误:WindowsError: [Error 2] 系统找不到指定的文件,这个错误是在上面程序的第3行调用时发生的。我知道我这里缺少了一些很简单的东西,可能和Popen有关,有人能帮我看看是什么原因导致这个错误吗?为什么会提示找不到文件呢?
2 个回答
0
在Windows上安装Ghostscript,并在环境变量中设置路径,然后执行以下命令。
命令 = ["gswin32c",
"-q",
"-g%dx%d" % size,
"-dNOPAUSE -dSAFER",
"-sDEVICE=ppmraw",
"-sOutputFile=%s" % file
]
命令 = string.join(命令)
gs = os.popen(命令, "w")
2
试试在 Popen 中加上 shell=True
这个参数。我觉得这样可以让程序通过命令行的路径来找到可执行的程序。