我正在尝试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/