LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
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.

Notices


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

Rep: Reputation: 6
Cairo/Python issues with WeasyPrint


Hi,

I successfully installed WeasyPrint.
Cairo is installed too.
I get this error when executing WeasyPrint:
Code:
Traceback (most recent call last):
  File "./WeasyPrint/weasyprint.py", line 2, in <module>
    from weasyprint.__main__ import main
  File "/home/root/WeasyPrint/weasyprint/__init__.py", line 336, in <module>
    from .css import PARSER, preprocess_stylesheet  # noqa
  File "/home/root/WeasyPrint/weasyprint/css/__init__.py", line 30, in <module>
    from . import computed_values
  File "/home/root/WeasyPrint/weasyprint/css/computed_values.py", line 18, in <module>
    from .. import text
  File "/home/root/WeasyPrint/weasyprint/text.py", line 18, in <module>
    import cairocffi as cairo
  File "/root/.local/lib64/python3.4/site-packages/cairocffi/__init__.py", line 46, in <module>
    cairo = dlopen(ffi, 'cairo', 'cairo-2')
  File "/root/.local/lib64/python3.4/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 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.

Thanks!
 
Old 07-09-2016, 07:05 PM   #2
MisterBark
Member
 
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:
Code:
/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:
Code:
# ldd libcairo.so.2.11200.16
        linux-gate.so.1 (0xe1cf9000)
        libpthread.so.0 => /lib/libpthread.so.0 (0xe1ba4000)
        libpixman-1.so.0 => not found
        libfontconfig.so.1 => not found
        libfreetype.so.6 => /usr/lib/libfreetype.so.6 (0xe1af0000)
        libEGL.so.1 => not found
        libdl.so.2 => /lib/libdl.so.2 (0xe1aeb000)
        libpng14.so.14 => /usr/lib/libpng14.so.14 (0xe1abf000)
        libxcb-shm.so.0 => not found
        libxcb-render.so.0 => not found
        libxcb.so.1 => not found
        libXrender.so.1 => not found
        libX11.so.6 => not found
        libXext.so.6 => not found
        libz.so.1 => /usr/lib/libz.so.1 (0xe1aa8000)
        libGL.so.1 => not found
        librt.so.1 => /lib/librt.so.1 (0xe1a9f000)
        libm.so.6 => /lib/libm.so.6 (0xe1a5c000)
        libc.so.6 => /lib/libc.so.6 (0xe18d0000)
        /lib/ld-linux.so.2 (0xe1cfa000)
        libbz2.so.1 => /lib/libbz2.so.1 (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!
 
  


Reply

Tags
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

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

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

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