如何在pythonanywhere中安装django-wkhtmltopdf。?
当我尝试使用pip3安装时。已经很满足了当我运行项目时,其服务器错误(500)
Bash控制台
Requirement already satisfied: django-wkhtmltopdf in ./.local/lib/python3.7/site-packages (3.2.0)
服务器错误日志
FileNotFoundError: [Errno 2] No such file or directory: 'wkhtmltopdf': 'wkhtmltopdf'
wkhtmltopdf可以在任何地方安装在Python上吗?
[当我选择AWS服务器时,是否会遇到类似的问题? AWS是否支持wkhtmltopdf。?
如何解决。我的整个项目取决于PDF报告
我不确定pythonanywhere,但是在Windows中,我下载了wkhtmltox.zip,在其中找到了wkhtmltox.exe
。您还需要安装wkhtmltox
的pip包。
import imgkit
config_img = imgkit.config(wkhtmltoimage='../path_of_wkhtmltopdf/wkhtmltox.exe') #in windows
config_img = imgkit.config(wkhtmltoimage='../path_of_wkhtmltopdf/wkhtmltox') #in linux
imgkit.from_string(html, file_path + '.jpg', config=config_img)
for pythonanywhere
从wkhtmltox
的file
部分中存在的上传选项中上传pythonanywhere
文件。
检查当前目录并列出该目录中的文件并找到您的文件。
import os
print(os.getcwd()) # current directory path
print(os.listdir(os.getcwd()) # list files present in current directory