WeasyPrint: WeasyPrint fails with error on OSX 10.7.5/homebrew

I’ve got the following versions of the requirements installed:

$ brew install python cairo pango gdk-pixbuf libxml2 libxslt libffi
Warning: python-2.7.4 already installed
Warning: cairo-1.12.14 already installed
Warning: pango-1.34.0 already installed
Warning: gdk-pixbuf-2.28.1 already installed
Warning: libxml2-2.9.0 already installed
Warning: libxslt-1.1.28 already installed
Warning: libffi-3.0.13 already installed

And when I install using mktmpenv --system-site-packages -i WeasyPrint, I get this output.

When I run WeasyPrint, I get the following:

Traceback (most recent call last):
  File "/Users/brian.hicks/.virtualenvs/ad1794530a0bf80f/bin/weasyprint", line 9, in <module>
    load_entry_point('WeasyPrint==0.19', 'console_scripts', 'weasyprint')()
  File "/Users/brian.hicks/.venvburrito/lib/python/distribute-0.6.35-py2.7.egg/pkg_resources.py", line 343, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/Users/brian.hicks/.venvburrito/lib/python/distribute-0.6.35-py2.7.egg/pkg_resources.py", line 2309, in load_entry_point
    return ep.load()
  File "/Users/brian.hicks/.venvburrito/lib/python/distribute-0.6.35-py2.7.egg/pkg_resources.py", line 2015, in load
    entry = __import__(self.module_name, globals(),globals(), ['__name__'])
  File "/Users/brian.hicks/.virtualenvs/ad1794530a0bf80f/lib/python2.7/site-packages/weasyprint/__init__.py", line 304, in <module>
    from .css import PARSER, preprocess_stylesheet
  File "/Users/brian.hicks/.virtualenvs/ad1794530a0bf80f/lib/python2.7/site-packages/weasyprint/css/__init__.py", line 30, in <module>
    from . import computed_values
  File "/Users/brian.hicks/.virtualenvs/ad1794530a0bf80f/lib/python2.7/site-packages/weasyprint/css/computed_values.py", line 18, in <module>
    from .. import text
  File "/Users/brian.hicks/.virtualenvs/ad1794530a0bf80f/lib/python2.7/site-packages/weasyprint/text.py", line 18, in <module>
    import cairocffi as cairo
  File "/Users/brian.hicks/.virtualenvs/ad1794530a0bf80f/lib/python2.7/site-packages/cairocffi/__init__.py", line 36, in <module>
    cairo = dlopen(ffi, 'libcairo.so.2', 'libcairo-2.dll', 'cairo', 'libcairo-2')
  File "/Users/brian.hicks/.virtualenvs/ad1794530a0bf80f/lib/python2.7/site-packages/cairocffi/__init__.py", line 31, in dlopen
    return ffi.dlopen(names[0])  # pragma: no cover
  File "/Users/brian.hicks/.virtualenvs/ad1794530a0bf80f/lib/python2.7/site-packages/cffi/api.py", line 111, in dlopen
    lib, function_cache = _make_ffi_library(self, name, flags)
  File "/Users/brian.hicks/.virtualenvs/ad1794530a0bf80f/lib/python2.7/site-packages/cffi/api.py", line 364, in _make_ffi_library
    raise OSError("library not found: %r" % (name,))
OSError: library not found: 'libcairo.so.2'

About this issue

  • Original URL
  • State: closed
  • Created 11 years ago
  • Comments: 18 (6 by maintainers)

Most upvoted comments

Hi, I have just got the same issue on Mac 10.8.4. Investigated an issue and localization gave me, that:

$ brew install cairo

- returned HTTP 404 error for glib dependency So, I just made:

$ brew update

After that both installation of cairo and running weasyprint were fine:

$ brew install cairo pango gdk-pixbuf libxml2 libxslt libffi
$ pip install WeasyPrint
$ weasyprint --help

- worked for me

$ export DYLD_FALLBACK_LIBRARY_PATH=/opt/local/lib

Fixes the issue with macports.

https://github.com/Kozea/WeasyPrint/issues/79#issuecomment-28835056

I can confirm that DYLD_FALLBACK_LIBRARY_PATH solution works with Python 3.4 and macports. I could be useful to put this export into ~/.profile.