问题
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?
回答1:
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.
回答2:
i solve it installing it this way, i hope it work for you
pip install django-wkhtmltopdf
回答3:
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()
回答4:
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.)
来源:https://stackoverflow.com/questions/29533177/no-module-named-main-wkhtmltopdf-issue