berthertogen / weasyprint.wrapped

A .netstandaard wrapper for the weasyprint PDF printer. This package is standalone and does not required you to install any software on your server. It runs on windows and linux.
BSD 3-Clause "New" or "Revised" License
25 stars 7 forks source link

Can not load library errors on windows #32

Closed ivan-burlakov closed 2 years ago

ivan-burlakov commented 2 years ago

Hello,

First of all, thanks a lot for the great wrapper.

I faced with can not load library errors when was using the nuget package locally on my PC. For instance, I got following error on executing await printer.Version() in Weasyprint.Wrapped.Example:

Version
 - ExitCode:            1
 - HasError:            True
 - Error:               Traceback (most recent call last):
  File "C:\Users\usrname\weasyprint.wrapped\src\Weasyprint.Wrapped.Example\bin\Debug\net6.0\weasyprinter\python\lib\runpy.py", line 187, in _run_module_as_main
    mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
  File "C:\Users\usrname\weasyprint.wrapped\src\Weasyprint.Wrapped.Example\bin\Debug\net6.0\weasyprinter\python\lib\runpy.py", line 146, in _get_module_details
    return _get_module_details(pkg_main_name, error)
  File "C:\Users\usrname\weasyprint.wrapped\src\Weasyprint.Wrapped.Example\bin\Debug\net6.0\weasyprinter\python\lib\runpy.py", line 110, in _get_module_details
    __import__(pkg_name)
  File "C:\Users\usrname\weasyprint.wrapped\src\Weasyprint.Wrapped.Example\bin\Debug\net6.0\weasyprinter\python\lib\site-packages\weasyprint\__init__.py", line 336, in <module>
    from .css import preprocess_stylesheet  # noqa isort:skip
  File "C:\Users\usrname\weasyprint.wrapped\src\Weasyprint.Wrapped.Example\bin\Debug\net6.0\weasyprinter\python\lib\site-packages\weasyprint\css\__init__.py", line 25, in <module>
    from . import computed_values, counters, media_queries
  File "C:\Users\usrname\weasyprint.wrapped\src\Weasyprint.Wrapped.Example\bin\Debug\net6.0\weasyprinter\python\lib\site-packages\weasyprint\css\computed_values.py", line 9, in <module>
    from ..text.ffi import ffi, pango, units_to_double
  File "C:\Users\usrname\weasyprint.wrapped\src\Weasyprint.Wrapped.Example\bin\Debug\net6.0\weasyprinter\python\lib\site-packages\weasyprint\text\ffi.py", line 401, in <module>
    pango = _dlopen(
  File "C:\Users\usrname\weasyprint.wrapped\src\Weasyprint.Wrapped.Example\bin\Debug\net6.0\weasyprinter\python\lib\site-packages\weasyprint\text\ffi.py", line 385, in _dlopen
    return ffi.dlopen(names[0])  # pragma: no cover
  File "C:\Users\usrname\weasyprint.wrapped\src\Weasyprint.Wrapped.Example\bin\Debug\net6.0\weasyprinter\python\lib\site-packages\cffi\api.py", line 150, in dlopen
    lib, function_cache = _make_ffi_library(self, name, flags)
  File "C:\Users\usrname\weasyprint.wrapped\src\Weasyprint.Wrapped.Example\bin\Debug\net6.0\weasyprinter\python\lib\site-packages\cffi\api.py", line 832, in _make_ffi_library
    backendlib = _load_backend_lib(backend, libname, flags)
  File "C:\Users\usrname\weasyprint.wrapped\src\Weasyprint.Wrapped.Example\bin\Debug\net6.0\weasyprinter\python\lib\site-packages\cffi\api.py", line 827, in _load_backend_lib
    raise OSError(msg)
OSError: cannot load library 'pango-1.0-0': error 0x7e.  Additionally, ctypes.util.find_library() did not manage to locate a library called 'pango-1.0-0'

It looks like some king of environmental issues when python can not find gtk libraries.

Thanks Ivan.

ivan-burlakov commented 2 years ago

The fix is to reorder PATH environment variables which are set up when running weasyprint: https://github.com/berthertogen/weasyprint.wrapped/pull/33.

berthertogen commented 2 years ago

Thank you very much for the contribution! Your fix is released in v2.0.1 :), I will also release v3.0.0 today with an upgrade to weasyprint 57.

ivan-burlakov commented 2 years ago

Thank you very much for supporting the tool!