pydf icon indicating copy to clipboard operation
pydf copied to clipboard

OSError - %1 is not a valid Win32 application

Open sbi-rviot opened this issue 5 years ago • 3 comments

I am running the basic example as follow:

import pydf
pdf = pydf.generate_pdf('<h1>this is html</h1>')
with open('test_doc.pdf', 'wb') as f:
    f.write(pdf)

and I get the following error:

Traceback (most recent call last):
  File "pdytest.py", line 2, in <module>
    pdf = pydf.generate_pdf('<h1>this is html</h1>')
  File "C:\Program Files\Python37\lib\site-packages\pydf\wkhtmltopdf.py", line 145, in generate_pdf
    p = _execute_wk(*cmd_args, input=html.encode())
  File "C:\Program Files\Python37\lib\site-packages\pydf\wkhtmltopdf.py", line 30, in _execute_wk
    return subprocess.run(wk_args, input=input, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
  File "C:\Program Files\Python37\lib\subprocess.py", line 472, in run
    with Popen(*popenargs, **kwargs) as process:
  File "C:\Program Files\Python37\lib\subprocess.py", line 775, in __init__
    restore_signals, start_new_session)
  File "C:\Program Files\Python37\lib\subprocess.py", line 1178, in _execute_child
    startupinfo)
OSError: [WinError 193] %1 is not a valid Win32 application

I am using python 3.7. Could you please help? Thank you.

sbi-rviot avatar Jan 21 '20 20:01 sbi-rviot

I'm afraid I don't run windows so can't fix this directly.

I suspect it's related to the path separator in the executor path.

If you can fix, happy to accept a PR.

samuelcolvin avatar Jan 22 '20 00:01 samuelcolvin

I have the same issue on Windows. If someone could fix it it would be great.

vapavlov avatar Jul 05 '21 15:07 vapavlov

1 - here image 2 - WKHTMLTOPDF_PATH / C:\Program Files\wkhtmltopdf\bin\wkhtmltopdf.exe image 3- and reset your computer

davilos avatar Feb 22 '22 18:02 davilos