Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.


  Search this Thread
Old 07-09-2016, 03:47 PM   #1
Registered: Jul 2012
Location: Republic of Krakozhia
Distribution: Slackware & Zenwalk core + compile
Posts: 104

Rep: Reputation: 6
Cairo/Python issues with WeasyPrint


I successfully installed WeasyPrint.
Cairo is installed too.
I get this error when executing WeasyPrint:
Traceback (most recent call last):
  File "./WeasyPrint/", line 2, in <module>
    from weasyprint.__main__ import main
  File "/home/root/WeasyPrint/weasyprint/", line 336, in <module>
    from .css import PARSER, preprocess_stylesheet  # noqa
  File "/home/root/WeasyPrint/weasyprint/css/", line 30, in <module>
    from . import computed_values
  File "/home/root/WeasyPrint/weasyprint/css/", line 18, in <module>
    from .. import text
  File "/home/root/WeasyPrint/weasyprint/", line 18, in <module>
    import cairocffi as cairo
  File "/root/.local/lib64/python3.4/site-packages/cairocffi/", line 46, in <module>
    cairo = dlopen(ffi, 'cairo', 'cairo-2')
  File "/root/.local/lib64/python3.4/site-packages/cairocffi/", 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 seems to be a common problem that no one really understands, I found plenty of topics on the net, but mostly for MacOS.

I tried to reinstall cairo libs, and the cairo and cairocffi of python, same thing.

My machine:
Slackware64, very customized, kernel grsec, no X.

I have another Slackware64 on a desktop, less minimal, and it works.
I can't figure out what makes the difference.

Any suggestions on what to try?
NOTE: I cannot reboot that server, but I mounted /usr in ramfs so I can experiment a bit without messing up the real /usr directory.

Old 07-09-2016, 07:05 PM   #2
Registered: Jul 2012
Location: Republic of Krakozhia
Distribution: Slackware & Zenwalk core + compile
Posts: 104

Original Poster
Rep: Reputation: 6
Ok so for anyone passing by here and still struggling with that, I found the problem.
In my case it was because cairo libs were there, but they need X and my system (a server) had no X. Unfortunately once in Python it didn't explain what was wrong with cairo.

So, to check if python finds cairo:
/usr/bin/python2.7 -c "import ctypes.util; print ctypes.util.find_library('cairo')"
That should return you the file name of the lib being used. If not, it means that python cannot find cairo, so make sure it does.
Now, if it does, you wanna look at what this lib depends on:

In my case:
# ldd (0xe1cf9000) => /lib/ (0xe1ba4000) => not found => not found => /usr/lib/ (0xe1af0000) => not found => /lib/ (0xe1aeb000) => /usr/lib/ (0xe1abf000) => not found => not found => not found => not found => not found => not found => /usr/lib/ (0xe1aa8000) => not found => /lib/ (0xe1a9f000) => /lib/ (0xe1a5c000) => /lib/ (0xe18d0000)
        /lib/ (0xe1cfa000) => /lib/ (0xe18bf000)
As you can see some X libs are missing.
So either you install X, which is really too heavy for a clean server IMO, or you find just the libs it needs.
I copied these files from another Slackware64 same version, and it worked! (I basically copied libX* and a few more to make sure they are all here)
If it doesn't, run ldd on each of these libs listed to see if they miss even more.

Then I had some pango issues with fonts but copying some pango module files and creating ~/.fonts/ with the ttf inside solved the problem.

Best luck!


cairo, python

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
RRDtool build/cairo issues without X Strykar Slackware 13 09-11-2019 07:00 PM
[SOLVED] Python Script Issues metallica1973 Programming 3 05-10-2013 02:07 PM
LXer: Cairo 1.12.14 Fixes Various Issues LXer Syndicated Linux News 0 02-13-2013 01:30 AM
Cairo Dock Theme issues Mortis1369 Linux - Newbie 4 03-08-2010 03:58 PM
dpkg: error processing python-cairo (--configure) ronaldv Ubuntu 3 10-13-2009 01:06 PM > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 06:49 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration