Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Python by (50.2k points)

I am trying to convert the webpage into PDF by using Python but I am getting one error message:

'ImportError: No module named PyQt4.QtCore', and 'ImportError: No module named PyQt4.QtCore'.

1 Answer

0 votes
by (107k points)

You have to use the pdfkit package from Python:

import pdfkit

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

Below are the installation codes for the different os:

macOS: brew install Caskroom/cask/wkhtmltopdf

Debian/Ubuntu: apt-get install wkhtmltopdf

Windows: choco install wkhtmltopdf

 

Related questions

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...