Trouble running WeasyPrint after installing El Capitan (OSX 10.11)

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-25 12:42:11

问题


I recently updated my OS on my mac to El Capitan and since then have been running into issues trying to run WeasyPrint. I have updated macports, uninstalled and reinstalled all of the macport dependencies. I've also uninstalled and reinstalled WeasyPrint via pip with no issues, but still it doesn't run. I also have the export DYLD_FALLBACK_LIBRARY_PATH="/opt/local/lib" in my ~/.profile which helped solve the import errors and allowed WeasyPrint to run before I had El Capitan installed. When i type weasyprint --help into the terminal i get the following output/error:

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

It looks like a path problem, but I've tried everything i can think of. Any suggestions?


回答1:


Ok so I found a solution (without changing any of the original weasyprint or cairocffi files). Apparently OS X 10.11 introduces SIP which disables the use of DYLD path variables. To get around this I disabled SIP. The instructions to do so are here. Basically hold command + r when booting up. Click utilities at the top and go into the terminal. type in csrutil disable then reboot and that should fix it.



来源:https://stackoverflow.com/questions/33530911/trouble-running-weasyprint-after-installing-el-capitan-osx-10-11

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!