OSError: [Errno 8] Exec format error
dbinetti opened this issue · comments
Not sure if this library is still supported, but FWIW:
Python 3.6.2 (default, Jul 17 2017, 16:44:45)
Type 'copyright', 'credits' or 'license' for more information
IPython 6.2.1 -- An enhanced Interactive Python. Type '?' for help.
In [1]: import pydf
In [2]: p = pydf.generate_pdf('http://www.google.com')
---------------------------------------------------------------------------
OSError Traceback (most recent call last)
<ipython-input-2-911a3ffb27a6> in <module>()
----> 1 p = pydf.generate_pdf('http://www.google.com')
~/.virtualenvs/barberscore-api/lib/python3.6/site-packages/pydf/wkhtmltopdf.py in generate_pdf(html, cache_dir, grayscale, lowquality, margin_bottom, margin_left, margin_right, margin_top, orientation, page_height, page_width, page_size, image_dpi, image_quality, **extra_kwargs)
143 cmd_args = _convert_args(**py_args)
144
--> 145 p = _execute_wk(*cmd_args, input=html.encode())
146 pdf_content = p.stdout
147
~/.virtualenvs/barberscore-api/lib/python3.6/site-packages/pydf/wkhtmltopdf.py in _execute_wk(input, *args)
28 """
29 wk_args = (WK_PATH,) + args
---> 30 return subprocess.run(wk_args, input=input, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
31
32
/usr/local/Cellar/python3/3.6.2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/subprocess.py in run(input, timeout, check, *popenargs, **kwargs)
401 kwargs['stdin'] = PIPE
402
--> 403 with Popen(*popenargs, **kwargs) as process:
404 try:
405 stdout, stderr = process.communicate(input, timeout=timeout)
/usr/local/Cellar/python3/3.6.2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/subprocess.py in __init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, encoding, errors)
705 c2pread, c2pwrite,
706 errread, errwrite,
--> 707 restore_signals, start_new_session)
708 except:
709 # Cleanup if the child failed starting.
/usr/local/Cellar/python3/3.6.2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/subprocess.py in _execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, restore_signals, start_new_session)
1331 else:
1332 err_msg += ': ' + repr(orig_executable)
-> 1333 raise child_exception_type(errno_num, err_msg)
1334 raise child_exception_type(err_msg)
1335
OSError: [Errno 8] Exec format error
Is definitely still supported, what made you think otherwise?
What os are you using? Does it work when converting raw html?
What processor architecture are you on?
Pydf comes bundled with a binary for amd64, if you're on another architecture you'll need to supply your own binary.
You'll need to download a binary for wkhtmltopdf which works on mac and set the WKHTMLTOPDF_PATH
environment variable so pydf uses it. I've added a note to the beginning of the readme to that effect.
There haven't been any changes over the last 6 months because wkthmltopdf hasn't released a new stable version and nothing has gone wrong. When I say "nothing" I mean TutorCruncher alone generates well over 1m pdfs a month with pydf, both using the pypi package and the docker container; I can't remember a single error over that time with pydf.