3

I'm trying to make PDFs out of HTML files and URLs. I've found wkhtmltopdf to be just what I'm looking for, and the Python wrapper, pdfkit, seems great too.

However, when I try to run the basic script:

import pdfkit
pdfkit.from_url('http://google.com', 'out.pdf')

In either Wing IDE or Sublime Text 2, I get this error:

AttributeError: 'module' object has no attribute 'from_url'

The strange part is, it works fine when I do it at the command line or in the Wing IDE shell.

I assume this has something to do with how pdfkit is installed in sitepackages, but I don't know enough about the intricacies of those to figure out how to fix the issue. Can anyone help?

I'm using Python 2.7, Wing IDE 4.1.11-1, Sublime Text 2.0.2 on Windows 7.

Thanks a lot, Alex

Alex S
  • 4,726
  • 7
  • 39
  • 67
  • 1
    Is it possible you have a source file called pdfkit.py? If so, hat is probably being imported instead and thus does not contain from_url. Try adding as line 2 "print(pdfkit.__file__" to see if it's the file you think it is. – Wingware Apr 13 '15 at 20:01
  • Ah you're right, I stupidly made a file called pdfkit.py in the same folder. Thanks a lot. – Alex S Apr 13 '15 at 20:10

1 Answers1

3

As Wingware pointed out, I had a file called pdfkit.py in the same folder as the script. Instead of importing the module it was importing that file, which of course was almost empty.

Thanks Wingware.

Alex S
  • 4,726
  • 7
  • 39
  • 67