jmaupetit / md2pdf

Markdown to PDF conversion tool
MIT License
254 stars 42 forks source link

OSError: cannot load library 'pango-1.0-0' #68

Open augustus-thomas opened 6 months ago

augustus-thomas commented 6 months ago

Usage

I am using this repository as a package after installing with pip3 install md2pdf I am importing the package as suggested in the Readme with from md2pdf.core import md2pdf

OS

I am running Windows Subsystem for Linux

Traceback

Traceback (most recent call last):                                                     
  File "<stdin>", line 1, in <module>                                                  
  File "/mnt/c/Users/augus/noteworthy/backend.py", line 7, in <module>                 
    from md2pdf.core import md2pdf                                                     
  File "/home/awth/.local/lib/python3.10/site-packages/md2pdf/__init__.py", line 7, in 
<module>                                                                               
    from .core import md2pdf  # noqa                                                   
  File "/home/awth/.local/lib/python3.10/site-packages/md2pdf/core.py", line 5, in <module>                                                                                   
    from weasyprint import HTML, CSS                                                   
  File "/home/awth/.local/lib/python3.10/site-packages/weasyprint/__init__.py", line 419, in <module>                                                                         
    from .css import preprocess_stylesheet  # noqa isort:skip                          
  File "/home/awth/.local/lib/python3.10/site-packages/weasyprint/css/__init__.py", line 27, in <module>                                                                      
    from .computed_values import COMPUTER_FUNCTIONS                                    
  File "/home/awth/.local/lib/python3.10/site-packages/weasyprint/css/computed_values.py", line 9, in <module>                                                                
    from ..text.ffi import ffi, pango, units_to_double                                 
  File "/home/awth/.local/lib/python3.10/site-packages/weasyprint/text/ffi.py", line 431, in <module>                                                                         
    pango = _dlopen(                                                                   
  File "/home/awth/.local/lib/python3.10/site-packages/weasyprint/text/ffi.py", line 417, in _dlopen                                                                          
    return ffi.dlopen(names[0])  # pragma: no cover                                    
  File "/home/awth/.local/lib/python3.10/site-packages/cffi/api.py", line 150, in dlopen                                                                                      
    lib, function_cache = _make_ffi_library(self, name, flags)                         
  File "/home/awth/.local/lib/python3.10/site-packages/cffi/api.py", line 832, in _make_ffi_library                                                                           
    backendlib = _load_backend_lib(backend, libname, flags)                            
  File "/home/awth/.local/lib/python3.10/site-packages/cffi/api.py", line 827, in _load_backend_lib                                                                           
    raise OSError(msg)                                                                 
OSError: cannot load library 'pango-1.0-0': pango-1.0-0: cannot open shared object file: No such file or directory.  Additionally, ctypes.util.find_library() did not manage to locate a library called 'pango-1.0-0'
jmaupetit commented 5 months ago

Hi @augustus-thomas!

This issue is related to WeasyPrint! Did you follow the installation instructions from the documentation? Pay attention to the GTK3 requirement.

rcking commented 3 months ago

Thank you - but WeasyPrint in turn depends on pango, and it is not obvious how to install that. For Ubuntu 20.04 and 22.04 I found this article. In short, for 22.04:

sudo apt-get -y install libcogl-pango-dev

worked for me. Not perfect, as it is outside of the virtual environment. But now md2pdf works!