Django-easy-pdf:需要xhtml2pdf reportlab2.2+,但安装了3.0
题
我想给 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
, ,该软件被安装没有问题。
但是,在启动Django1.6时,我得到: ImportError: Reportlab Version 2.1+ is needed!
.
我确实安装了reportlab2.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中可用的版本。首先卸载xhtml2pdf和pypdf使用 pip uninstall
, ,然后做:
pip install git+https://github.com/chrisglass/xhtml2pdf.git
不隶属于 StackOverflow