python - 需要 Django-easy-pdf : xhtml2pdf reporting reportlab 2. 2+,但已安装 3.0

标签 python django reportlab xhtml2pdf

我正在尝试django-easy-pdf,但在安装依赖项时遇到问题。

运行 Django 时,我收到 ImportError: No module named xhtml2pdf.default

为了尝试修复,我执行了pip install xhtml2pdf,但这会产生无法找到任何满足 pyPdf 要求的下载(来自 xhtml2pdf)

因此,让我们执行 pip install --allow-unverified pyPdf pyPdf 来解决这个问题。这一切顺利完成。重复 pip install xhtml2pdf 时,软件安装不会出现问题。

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

不过,我确实安装了 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"

如何解决此问题(除了从源中删除这些检查之外)?

最佳答案

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

django-easy-pdf depends on:
  django>=1.5.1
  git+https://github.com/chrisglass/xhtml2pdf.git

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

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

关于python - 需要 Django-easy-pdf : xhtml2pdf reporting reportlab 2. 2+,但已安装 3.0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23058493/

相关文章:

python - Matplotlib注释详细文档

javascript - 使用 javascript/Jquery 在 MouseOver 之后删除元素的颜色

javascript - 我的 Django/Python 代码不在 HTML 页面中呈现 HTML <a> 标记

python - 不会为自定义用户模型保存配置文件数据

python - "Error when calling the metaclass bases"在模块内声明类时

python - 在 Windows 7 中为 Python 安装 selenium

python - 如何更改 matplotlib 图上的字体大小

Python ReportLab 段落计数打印的行数

python - ReportLab 和 Jython?

python - 抛出空白偶数页/左页