python - django-wkhtmltopdf 给出 "[Error 2] The system cannot find the file specified"?

标签 python django python-2.7 wkhtmltopdf

网址.py

from wkhtmltopdf.views import PDFTemplateView
url(r'^pdf/$', PDFTemplateView.as_view(template_name='base/template.html',
            filename='template.pdf', 
            header_template='base/header.html', 
            footer_template='base/header.html', 
            ), name='pdf')

cmd在我的settings.py文件中配置如下所示

WKHTMLTOPDF_CMD = "C:\Python27\Lib\site-packages\wkhtmltopdf"

我仍然得到同样的错误

已解决

这个问题已经解决了 通过在路径中用反斜杠替换正斜杠,如下所示

WKHTMLTOPDF_CMD = "C:/Python27/Lib/site-packages/wkhtmltopdf"

现在我收到一个新错误“[错误 5] 访问被拒绝”

最佳答案

WKHTMLTOPDF_CMD 应该指向 wkhtmlpdf.exe 二进制文件,它是独立于 wkhtmltopdf python 包的安装。

their website 下载二进制文件

关于python - django-wkhtmltopdf 给出 "[Error 2] The system cannot find the file specified"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27375391/

相关文章:

python - 自定义上下文处理器在 Django 1.8.2 中不起作用

python - 为什么 *args 不适用于字符串格式

python - 在实例化时自动调用 Python 类方法的最佳方法

python - 获取列表中多次出现的项目的唯一列表

java - 如何创建其中包含 map 的查询字符串? ( java )

python - 在opencv2中使用3D感知

python - 如何通过正则表达式从数据框中选择列

python - 名称和函数体如何存储在 Python 代码对象中?

django - 如何在 django rest 框架中存储外键字段?

django - 多对多字段的所有值:Django