Django-easy-pdf:xhtml2pdf报告reportlab 2.2+是必需的,但安装了3.0

Sae*_*aeX 2 python django reportlab xhtml2pdf

我想尝试django-easy-pdf一下,但是我在安装依赖项时遇到了问题.

ImportError: No module named xhtml2pdf.default在运行Django时得到了.

为了尝试修复,我做了一个pip install xhtml2pdf,但是产生了Could not find any downloads that satisfy the requirement pyPdf (from xhtml2pdf).

所以,让我们pip install --allow-unverified pyPdf pyPdf来解决这个问题.这完成没有问题.重复时pip install xhtml2pdf,软件安装没有问题.

但是,当启动Django 1.6时,我得到:ImportError: Reportlab Version 2.1+ is needed!.

我确实安装了reportlab 2.2或更高版本,因为pip freeze列表3.0.

它看起来像是在几个文件(util.py__init__.py)中硬编码:

if not (reportlab.Version[0] == "2" and reportlab.Version[2] >= "1"):
    raise ImportError("Reportlab Version 2.1+ is needed!")

if not REPORTLAB22:
    raise ImportError, "Reportlab Toolkit Version 2.2 or higher needed"
Run Code Online (Sandbox Code Playgroud)

如何修复(除了从源中删除这些检查)?

Sae*_*aeX 5

作者在https://github.com/nigma/django-easy-pdf上提及:

django-easy-pdf depends on:
  django>=1.5.1
  git+https://github.com/chrisglass/xhtml2pdf.git
Run Code Online (Sandbox Code Playgroud)

需要安装该特定版本,而不是pypi中可用的版本.首先卸载xhtml2pdf和pypdf pip uninstall,然后执行:

pip install git+https://github.com/chrisglass/xhtml2pdf.git