如何在Pythonanywhere中安装django-wkhtmltopdf?

问题描述 投票:0回答:1

如何在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报告

django python-3.x amazon-web-services pythonanywhere
1个回答
0
投票

我不确定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

wkhtmltoxfile部分中存在的上传选项中上传pythonanywhere文件。

检查当前目录并列出该目录中的文件并找到您的文件。

import os
print(os.getcwd())                   # current directory path

print(os.listdir(os.getcwd())        # list files present in current directory
© www.soinside.com 2019 - 2024. All rights reserved.