我最近将我的 Mac 上的操作系统更新为 El Capitan,从那时起在尝试运行 WeasyPrint 时遇到了问题。我已经更新了 macports,卸载并重新安装了所有 macport 依赖项。我还通过 pip 卸载并重新安装了 WeasyPrint,没有任何问题,但它仍然没有运行。我的 ~/.profile 中也有 export DYLD_FALLBACK_LIBRARY_PATH="/opt/local/lib" ,它有助于解决导入错误并允许 WeasyPrint 在我安装 El Capitan 之前运行。当我在终端中输入 weasyprint --help 时,我得到以下输出/错误:
File "main.py", line 14, in <module>
import nextline_webapp.quotes # pylint: disable=unused-import
File "/Users/joshsacks/NextLine/nextline_webapp/quotes.py", line 8, in <module>
from flask_weasyprint import HTML, render_pdf
File "/Library/Python/2.7/site-packages/flask_weasyprint/__init__.py", line 13, in <module>
import weasyprint
File "/Library/Python/2.7/site-packages/weasyprint/__init__.py", line 336, in <module>
from .css import PARSER, preprocess_stylesheet
File "/Library/Python/2.7/site-packages/weasyprint/css/__init__.py", line 30, in <module>
from . import computed_values
File "/Library/Python/2.7/site-packages/weasyprint/css/computed_values.py", line 18, in <module>
from .. import text
File "/Library/Python/2.7/site-packages/weasyprint/text.py", line 18, in <module>
import cairocffi as cairo
File "/Library/Python/2.7/site-packages/cairocffi/__init__.py", line 46, in <module>
cairo = dlopen(ffi, 'cairo', 'cairo-2')
File "/Library/Python/2.7/site-packages/cairocffi/__init__.py", line 43, in dlopen
raise OSError("dlopen() failed to load a library: %s" % ' / '.join(names))
OSError: dlopen() failed to load a library: cairo / cairo-2
它看起来像一个路径问题,但我已经尝试了我能想到的一切。有什么建议么?