python-2.7sublimetext2pdfkitwing-ide

pdfkit not importing correctly in editors


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


Solution

  • 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.