No module named main, wkhtmltopdf issue
Asked Answered
S

5

8

I'm new in python, but all search results i found was useless for me.

    C:\Users\Aero>pip install wkhtmltopdf
Collecting wkhtmltopdf
  Using cached wkhtmltopdf-0.2.tar.gz
Installing collected packages: wkhtmltopdf
  Running setup.py install for wkhtmltopdf
Successfully installed wkhtmltopdf-0.2

C:\Users\Aero>python
Python 3.4.3 (v3.4.3:9b73f1c3e601, Feb 24 2015, 22:43:06) [MSC v.1600 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import wkhtmltopdf
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python34\lib\site-packages\wkhtmltopdf\__init__.py", line 1, in <module>
    from main import WKhtmlToPdf, wkhtmltopdf
ImportError: No module named 'main'

That is happening all the time. Thanks for any help.

Update:
I find that installing Python 2.* makes it okay, cause of main module isn't correct while using print (Using 2.* version).
But i still want to know, it there any ways?

Steamroller answered 9/4, 2015 at 8:10 Comment(2)
Install the windows installerCollect
@Collect Windows installer is okay, but i want to use python for it.Steamroller
L
0

Seems there is some error with package installation of wkhtmltopdf. It wasn't working for me then i uninstalled the package and re-installed it by doing

python -m pip uninstall wkhtmltopdf

and then

python -m pip install wkhtmltopdf

it worked for me.try this it may work.

Laccolith answered 9/4, 2015 at 9:0 Comment(1)
So sorry to bother you! I was hoping you could point me to someone who can answer this question: #69367004 Thank you!Hinton
T
7

i solve it installing it this way, i hope it work for you

pip install django-wkhtmltopdf
Toscano answered 2/4, 2020 at 5:35 Comment(0)
K
2

It wasn't working for me for the first time, but after a PyCharm restart I could see anything. This might work for you: (Tested on Python 3.3.0)

import wkhtmltopdf
from wkhtmltopdf.main import WKhtmlToPdf

var = WKhtmlToPdf(
    url='http://www.example.com',
    output_file='~/example.pdf',
)
var.render()
Krisha answered 9/4, 2015 at 8:50 Comment(0)
F
1

If none of the other options work, it might be something wrong with your cache. Try uninstalling wkhtmltopdf and django-wkhtmltopdf and reinstalling without the cache:

pip uninstall django-wkhtmltopdf wkhtmltopdf
pip install --no-cache-dir wkhtmltopdf==0.2
pip install --no-cache-dir django-wkhtmltopdf==3.2.0

(Note that the above wkhtmltopdf and django-wkhtmltopdf version numbers may be different in your case.)

Fulmer answered 4/8, 2020 at 5:3 Comment(0)
L
0

Seems there is some error with package installation of wkhtmltopdf. It wasn't working for me then i uninstalled the package and re-installed it by doing

python -m pip uninstall wkhtmltopdf

and then

python -m pip install wkhtmltopdf

it worked for me.try this it may work.

Laccolith answered 9/4, 2015 at 9:0 Comment(1)
So sorry to bother you! I was hoping you could point me to someone who can answer this question: #69367004 Thank you!Hinton
R
0

The original python-wkhtmltopdf package has been archived in 2020: https://github.com/qoda/python-wkhtmltopdf

There is a fork available at https://pypi.org/project/py3-wkhtmltopdf/

Install with:

pip install py3-wkhtmltopdf

That seems to work for me.

Reiners answered 8/3 at 11:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.