PythonPDF: FileNotFoundError: [WinError 2] The system cannot find the file specified
PythonPDF: FileNotFoundError: [WinError 2] The system cannot find the file specified
当我使用 PDFJinja 的示例在现有 PDF 文件中填写表单字段时,我得到以下错误跟踪。
代码段:
dir_name = os.path.dirname("P:\Project\pdfjinja_services\resources\sample.pdf")
template_pdf_file = os.path.join(dir_name, 'sample.pdf')
template_pdf = PdfJinja(template_pdf_file, current_app.jinja_env)
print(type(template_pdf))
rendered_pdf = template_pdf({
'firstName': 'Faye',
'lastName': 'Valentine'
})
output_file = os.path.join(dir_name, 'output.pdf')
rendered_pdf.write(open(output_file, 'wb'))
错误:
Traceback (most recent call last):
File "P:\Professional\Python\CR\workspace\workspace-local\myplaybook\pdf_pdfjinja.py", line 10, in
rendered_pdf = template_pdf({
File "P:\Professional\Python\Softwares\python-3.9.6\lib\site-packages\pdfjinja.py", line 240, in call
filled = PdfFileReader(self.exec_pdftk(self.rendered))
File "P:\Professional\Python\Softwares\python-3.9.6\lib\site-packages\pdfjinja.py", line 212, in exec_pdftk
p = Popen(args, stdin=PIPE, stdout=PIPE, stderr=PIPE)
File "P:\Professional\Python\Softwares\python-3.9.6\lib\subprocess.py", line 951, in init
self._execute_child(args, executable, preexec_fn, close_fds,
File "P:\Professional\Python\Softwares\python-3.9.6\lib\subprocess.py", line 1420, in _execute_child
hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] The system cannot find the file specified
我正在使用 python-3.9.6 和 PDFJinja-1.1.0。
如果我缺少任何其他依赖项,请告诉我。
您缺少一个二进制文件(每个更新 pdftk),或者该二进制文件不在您的搜索路径中。
当我使用 PDFJinja 的示例在现有 PDF 文件中填写表单字段时,我得到以下错误跟踪。
代码段:
dir_name = os.path.dirname("P:\Project\pdfjinja_services\resources\sample.pdf")
template_pdf_file = os.path.join(dir_name, 'sample.pdf')
template_pdf = PdfJinja(template_pdf_file, current_app.jinja_env)
print(type(template_pdf))
rendered_pdf = template_pdf({
'firstName': 'Faye',
'lastName': 'Valentine'
})
output_file = os.path.join(dir_name, 'output.pdf')
rendered_pdf.write(open(output_file, 'wb'))
错误:
Traceback (most recent call last):
File "P:\Professional\Python\CR\workspace\workspace-local\myplaybook\pdf_pdfjinja.py", line 10, in
rendered_pdf = template_pdf({
File "P:\Professional\Python\Softwares\python-3.9.6\lib\site-packages\pdfjinja.py", line 240, in call
filled = PdfFileReader(self.exec_pdftk(self.rendered))
File "P:\Professional\Python\Softwares\python-3.9.6\lib\site-packages\pdfjinja.py", line 212, in exec_pdftk
p = Popen(args, stdin=PIPE, stdout=PIPE, stderr=PIPE)
File "P:\Professional\Python\Softwares\python-3.9.6\lib\subprocess.py", line 951, in init
self._execute_child(args, executable, preexec_fn, close_fds,
File "P:\Professional\Python\Softwares\python-3.9.6\lib\subprocess.py", line 1420, in _execute_child
hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] The system cannot find the file specified
我正在使用 python-3.9.6 和 PDFJinja-1.1.0。 如果我缺少任何其他依赖项,请告诉我。
您缺少一个二进制文件(每个更新 pdftk),或者该二进制文件不在您的搜索路径中。