Python Forum
pdfkit.from_string('Hello!','out.pdf') gives FileNotFoundError
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
pdfkit.from_string('Hello!','out.pdf') gives FileNotFoundError
#1
Question 
I am trying to use pdfkit library, one folder with permissions to write, and have also trying in root, who is in this case C:\, for example,

pdfkit.from_string('Hello!','out.pdf')
but dont know how to use it, because no matter what I do, I am always get:

Error:
INFO: Could not find files for the given pattern(s). Traceback (most recent call last): File "C:\Users\fabio\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pdfkit\configuration.py", line 21, in __init__ with open(self.wkhtmltopdf) as f: FileNotFoundError: [Errno 2] No such file or directory: b'' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "<stdin>", line 1, in <module> File "C:\Users\fabio\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pdfkit\api.py", line 70, in from_string configuration=configuration, cover_first=cover_first) File "C:\Users\fabio\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pdfkit\pdfkit.py", line 42, in __init__ self.configuration = (Configuration() if configuration is None File "C:\Users\fabio\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pdfkit\configuration.py", line 27, in __init__ 'https://github.com/JazzCore/python-pdfkit/wiki/Installing-wkhtmltopdf' % self.wkhtmltopdf) OSError: No wkhtmltopdf executable found: "b''" If this file exists please check that this process can read it. Otherwise please install wkhtmltopdf - https://github.com/JazzCore/python-pdf kit/wiki/Installing-wkhtmltopdf

I have even created an empty out.pdf file, and in another attempt, add also the complete path, but still same error.
Reply
#2
(Sep-18-2019, 01:19 PM)sipriusPT Wrote: Otherwise please install wkhtmltopdf
Install wkhtmltopdf.
Add C:\Program Files\wkhtmltopdf\bin to Environment Variables Path.
Reply
#3
I was trying to do this only through python 3 but its turning into a struggle.

I will have to use that pre compiled version with subprocess as a workaround only from html to pdf.

Thanks anyway snippsat!
Reply
#4
# pd_kit.py
import pdfkit

pdfkit.from_file('test.html', 'out_html.pdf')
pdfkit.from_string('Hello!', 'out.pdf')
Test run,from command line not editor.
E:\div_code
λ python pd_kit.py
Loading pages (1/6)
Counting pages (2/6)
Resolving links (4/6)
Loading headers and footers (5/6)
Printing pages (6/6)
Done
Loading pages (1/6)
Counting pages (2/6)
Resolving links (4/6)
Loading headers and footers (5/6)
Printing pages (6/6)
Done
Both pdf file works.

Test Windows Paths.
E:\div_code
λ python -V
Python 3.7.3

E:\div_code
λ pip -V
pip 19.2.3 from c:\python37\lib\site-packages\pip (python 3.7)

E:\div_code
λ wkhtmltopdf -V
wkhtmltopdf 0.12.5 (with patched qt)

E:\div_code
λ wkhtmltoimage -V
wkhtmltoimage 0.12.5 (with patched qt)
This is how it how it should look when works,
see that Path work dos not matter which folder you use if set correct in Environment Variables Path.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  FileNotFoundError: [WinError 2] The system cannot find the file specified NewBiee 2 1,562 Jul-31-2023, 11:42 AM
Last Post: deanhystad
  Need Help: FileNotFoundError:[Errno 2] No such file or directory python202209 5 2,636 Sep-12-2022, 04:50 AM
Last Post: python202209
  FileNotFoundError: [Errno 2] No such file or directory: 5l3y3r 6 8,108 Nov-02-2020, 12:48 PM
Last Post: 5l3y3r
  Shutil FileNotFoundError: Errno 2 Help lord_kaiser 8 10,512 Aug-10-2020, 08:45 AM
Last Post: lord_kaiser
  Getting FileNotFoundError: [Errno 2] ,if tries to acees same file from sub-directory pmpinaki 2 2,493 May-04-2020, 03:39 PM
Last Post: pmpinaki
  FileNotFoundError: [Errno 2] No such file or directory saqib1066 23 24,372 Mar-16-2020, 01:25 PM
Last Post: saqib1066
  FileNotFoundError managment sal 2 2,566 Oct-23-2019, 09:18 AM
Last Post: sal
  [split] FileNotFoundError...System cannot find the path specified powerrocker 1 2,047 Oct-03-2019, 09:09 AM
Last Post: buran
  FileNotFoundError: No such file or no access agatte 2 4,935 Sep-12-2019, 08:48 AM
Last Post: agatte
  FileNotFoundError...System cannot find the path specified alex9745 28 21,431 Jul-23-2019, 05:14 AM
Last Post: alex9745

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020