Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WeasyPrint fails with error on OSX 10.7.5/homebrew #79

Closed
BrianHicks opened this issue Apr 26, 2013 · 18 comments
Closed

WeasyPrint fails with error on OSX 10.7.5/homebrew #79

BrianHicks opened this issue Apr 26, 2013 · 18 comments

Comments

@BrianHicks
Copy link

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'
@SimonSapin
Copy link
Member

It looks like the install was successful, it’s only at runtime that dlopen() can not load dynamic libraries. Do you know what’s the full path of any .so or .dylib file installed by the cairo homebrew package? What are the values of the LD_LIBRARY_PATH, DYLD_LIBRARY_PATH, and DYLD_FALLBACK_LIBRARY_PATH environment variables?

@SimonSapin
Copy link
Member

Also, are you using the Python installed by Homebrew?

@BrianHicks
Copy link
Author

While I was getting the answers to those, I noticed the libcairo formula became keg-only, so it wasn't loaded into /usr/local/lib. Running brew link --force cairo fixed it for me.

@SimonSapin
Copy link
Member

I … am not sure what that means. Do you have suggestions for Homebrew instructions I could put in the documentation?

@BrianHicks
Copy link
Author

That means they figured it's on OSX by default so they shouldn't link it implicitly. There generally aren't too severe consequences for linking, but it's definitely something that varies on a case-by-case basis. Maybe just mention that it might be the case that it needs to be manually linked? That way people won't keep opening dumb bugs like this one. ;)

@SimonSapin
Copy link
Member

Ideally I’d like a set of instructions in the docs that people can follow even if they don’t care about pythons and virtualenvs and shared libraries. I’m trying to figure out what that is on OS X, but I don’t have a Mac to test on :/

@BrianHicks
Copy link
Author

A good goal to have! Unfortunately I'm not much help. I don't know enough about cairo and the programs which use it to be of any real assistance. Sorry. I'm willing to help test instructions though, should you need a hand.

@pelegrini
Copy link

Hi, @BrianHicks, I'm having the same problem but I am not using homebrew.

I'm using macports and installed like this:

daniel-mac:lib daniel$ sudo port install py26-lxml cairo pango gdk-pixbuf2 libffi
--->  Computing dependencies for py26-lxml
--->  Cleaning py26-lxml
--->  Computing dependencies for cairo
--->  Cleaning cairo
--->  Computing dependencies for pango
--->  Cleaning pango
--->  Computing dependencies for gdk-pixbuf2
--->  Cleaning gdk-pixbuf2
--->  Cleaning libffi
--->  Scanning binaries for linking errors: 100.0%
--->  No broken files found.

daniel-mac:lib daniel$ sudo pip install WeasyPrint
Requirement already satisfied (use --upgrade to upgrade): WeasyPrint in /Library/Python/2.6/site-packages
Requirement already satisfied (use --upgrade to upgrade): lxml in /Library/Python/2.6/site-packages (from WeasyPrint)
Requirement already satisfied (use --upgrade to upgrade): tinycss==0.3 in /Library/Python/2.6/site-packages (from WeasyPrint)
Requirement already satisfied (use --upgrade to upgrade): cssselect>=0.6 in /Library/Python/2.6/site-packages (from WeasyPrint)
Requirement already satisfied (use --upgrade to upgrade): CairoSVG>=0.4.1 in /Library/Python/2.6/site-packages (from WeasyPrint)
Requirement already satisfied (use --upgrade to upgrade): cffi>=0.6 in /Library/Python/2.6/site-packages (from WeasyPrint)
Requirement already satisfied (use --upgrade to upgrade): cairocffi>=0.4 in /Library/Python/2.6/site-packages (from WeasyPrint)
Requirement already satisfied (use --upgrade to upgrade): Pyphen in /Library/Python/2.6/site-packages (from WeasyPrint)
Requirement already satisfied (use --upgrade to upgrade): argparse in /Library/Python/2.6/site-packages (from WeasyPrint)
Requirement already satisfied (use --upgrade to upgrade): pycparser in /Library/Python/2.6/site-packages (from cffi>=0.6->WeasyPrint)
Cleaning up...

But I get the same error running WeasyPrint:

Traceback (most recent call last):
  File "/usr/local/bin/weasyprint", line 9, in <module>
    load_entry_point('WeasyPrint==0.19.1', 'console_scripts', 'weasyprint')()
  File "build/bdist.macosx-10.6-universal/egg/pkg_resources.py", line 337, in load_entry_point
  File "build/bdist.macosx-10.6-universal/egg/pkg_resources.py", line 2311, in load_entry_point
  File "build/bdist.macosx-10.6-universal/egg/pkg_resources.py", line 2017, in load
  File "/Library/Python/2.6/site-packages/weasyprint/__init__.py", line 304, in <module>
    from .css import PARSER, preprocess_stylesheet
  File "/Library/Python/2.6/site-packages/weasyprint/css/__init__.py", line 30, in <module>
    from . import computed_values
  File "/Library/Python/2.6/site-packages/weasyprint/css/computed_values.py", line 18, in <module>
    from .. import text
  File "/Library/Python/2.6/site-packages/weasyprint/text.py", line 18, in <module>
    import cairocffi as cairo
  File "/Library/Python/2.6/site-packages/cairocffi/__init__.py", line 36, in <module>
    cairo = dlopen(ffi, 'libcairo.so.2', 'libcairo-2.dll', 'cairo', 'libcairo-2')
  File "/Library/Python/2.6/site-packages/cairocffi/__init__.py", line 31, in dlopen
    return ffi.dlopen(names[0])  # pragma: no cover
  File "/Library/Python/2.6/site-packages/cffi/api.py", line 111, in dlopen
    lib, function_cache = _make_ffi_library(self, name, flags)
  File "/Library/Python/2.6/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'

Do you have an idea what should I do?

@BrianHicks
Copy link
Author

I haven't used port in a long time. Find out where they put libs and add it
to your path maybe? It's probably /usr/local/lib?
On Apr 30, 2013 6:36 PM, "pelegrini" notifications@github.com wrote:

Hi, @BrianHicks https://github.com/BrianHicks, I'm having the same
problem but I am not using homebrew.

I'm using macports and installed like this:

daniel-mac:lib daniel$ sudo port install py26-lxml cairo pango gdk-pixbuf2 libffi
---> Computing dependencies for py26-lxml
---> Cleaning py26-lxml
---> Computing dependencies for cairo
---> Cleaning cairo
---> Computing dependencies for pango
---> Cleaning pango
---> Computing dependencies for gdk-pixbuf2
---> Cleaning gdk-pixbuf2
---> Cleaning libffi
---> Scanning binaries for linking errors: 100.0%
---> No broken files found.

daniel-mac:lib daniel$ sudo pip install WeasyPrint
Requirement already satisfied (use --upgrade to upgrade): WeasyPrint in /Library/Python/2.6/site-packages
Requirement already satisfied (use --upgrade to upgrade): lxml in /Library/Python/2.6/site-packages (from WeasyPrint)
Requirement already satisfied (use --upgrade to upgrade): tinycss==0.3 in /Library/Python/2.6/site-packages (from WeasyPrint)
Requirement already satisfied (use --upgrade to upgrade): cssselect>=0.6 in /Library/Python/2.6/site-packages (from WeasyPrint)
Requirement already satisfied (use --upgrade to upgrade): CairoSVG>=0.4.1 in /Library/Python/2.6/site-packages (from WeasyPrint)
Requirement already satisfied (use --upgrade to upgrade): cffi>=0.6 in /Library/Python/2.6/site-packages (from WeasyPrint)
Requirement already satisfied (use --upgrade to upgrade): cairocffi>=0.4 in /Library/Python/2.6/site-packages (from WeasyPrint)
Requirement already satisfied (use --upgrade to upgrade): Pyphen in /Library/Python/2.6/site-packages (from WeasyPrint)
Requirement already satisfied (use --upgrade to upgrade): argparse in /Library/Python/2.6/site-packages (from WeasyPrint)
Requirement already satisfied (use --upgrade to upgrade): pycparser in /Library/Python/2.6/site-packages (from cffi>=0.6->WeasyPrint)
Cleaning up...

But I get the same error running WeasyPrint:

Traceback (most recent call last):
File "/usr/local/bin/weasyprint", line 9, in
load_entry_point('WeasyPrint==0.19.1', 'console_scripts', 'weasyprint')()
File "build/bdist.macosx-10.6-universal/egg/pkg_resources.py", line 337, in load_entry_point
File "build/bdist.macosx-10.6-universal/egg/pkg_resources.py", line 2311, in load_entry_point
File "build/bdist.macosx-10.6-universal/egg/pkg_resources.py", line 2017, in load
File "/Library/Python/2.6/site-packages/weasyprint/init.py", line 304, in
from .css import PARSER, preprocess_stylesheet
File "/Library/Python/2.6/site-packages/weasyprint/css/init.py", line 30, in
from . import computed_values
File "/Library/Python/2.6/site-packages/weasyprint/css/computed_values.py", line 18, in
from .. import text
File "/Library/Python/2.6/site-packages/weasyprint/text.py", line 18, in
import cairocffi as cairo
File "/Library/Python/2.6/site-packages/cairocffi/init.py", line 36, in
cairo = dlopen(ffi, 'libcairo.so.2', 'libcairo-2.dll', 'cairo', 'libcairo-2')
File "/Library/Python/2.6/site-packages/cairocffi/init.py", line 31, in dlopen
return ffi.dlopen(names[0]) # pragma: no cover
File "/Library/Python/2.6/site-packages/cffi/api.py", line 111, in dlopen
lib, function_cache = _make_ffi_library(self, name, flags)
File "/Library/Python/2.6/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'

Do you have an idea what should I do?


Reply to this email directly or view it on GitHubhttps://github.com//issues/79#issuecomment-17261018
.

@SimonSapin
Copy link
Member

Hi @pelegrini . I can’t seem to find the github issue again, but another Macports user had the same problem and resolved it by making sure to use the Python installed by Macports. Apparently it’s common on OS X to have Python install from multiple sources.

@pelegrini
Copy link

@BrianHicks, the location was /opt/local, but the $PATH was right.

@SimonSapin, it's a good idea, but I did not want to install another python26 in my machine...

What I did was uninstall macports completely and install homebrew. Although the problem persisted, brew link --force cairo worked for me.

Thanks very much for your help, guys.

@SimonSapin
Copy link
Member

So … suggestions for the install docs?

@pelegrini , I don’t think that the PATH env variable is relevant to shared library loading. LD_LIBRARY_PATH, DYLD_LIBRARY_PATH, and DYLD_FALLBACK_LIBRARY_PATH are.

@rogerhil
Copy link

It worked for me setting the correct path for DYLD_LIBRARY_PATH.

DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:/usr/local/Cellar/cairo/1.10.2/lib/

@ghost
Copy link

ghost commented Sep 21, 2013

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

@jmelett
Copy link

jmelett commented Nov 19, 2013

$ export DYLD_FALLBACK_LIBRARY_PATH=/opt/local/lib

Fixes the issue with macports.

@chrisbrownnwyc
Copy link

@jmelett thanks! This solved the issue for me and I'm still using the system python. (for many reasons I prefer to use it). I set the path and then reinstalled cairocffi with

 pip install --upgrade --force-reinstall cairoffi 

@bzamecnik
Copy link

#79 (comment)

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.

@derekjanni
Copy link

Just wanted to comment that I found this problem with Python 3.6 + MacOS High Sierra. Installed deps with brew as instructed but got similar complaints. Fixed via export DYLD_FALLBACK_LIBRARY_PATH=$DYLD_FALLBACK_LIBRARY_PATH:/usr/local/lib

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants