WhyNotHugo / django-renderpdf

📄 Django app to render django templates as PDF files.
https://django-renderpdf.readthedocs.io/
ISC License
67 stars 7 forks source link

Urgent Plz: after install thorugh pip and runserver got this below error #18

Closed milyas122 closed 1 year ago

milyas122 commented 3 years ago

OSError: cannot load library 'gobject-2.0-0': error 0x7e. Additionally, ctypes.util.find_library() did not manage to locate a library called 'gobject-2.0-0'

WhyNotHugo commented 3 years ago

Can you provide the entire error/traceback?

This doesn't look like a library we import directly.

AhmedSalam22 commented 2 years ago

me too image

AhmedSalam22 commented 2 years ago
Exception in thread django-main-thread:
Traceback (most recent call last):
  File "C:\Users\Ahmed Maher\AppData\Local\Programs\Python\Python38\lib\threading.py", line 932, in _bootstrap_inner
    self.run()
  File "C:\Users\Ahmed Maher\AppData\Local\Programs\Python\Python38\lib\threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "C:\Users\Ahmed Maher\AppData\Local\Programs\Python\Python38\lib\site-packages\django\utils\autoreload.py", line 64, in wrapper
    fn(*args, **kwargs)
  File "C:\Users\Ahmed Maher\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\management\commands\runserver.py", line 118, in inner_run
    self.check(display_num_errors=True)
  File "C:\Users\Ahmed Maher\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\management\base.py", line 419, in check
    all_issues = checks.run_checks(
  File "C:\Users\Ahmed Maher\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\checks\registry.py", line 76, in run_checks
    new_errors = check(app_configs=app_configs, databases=databases)
  File "C:\Users\Ahmed Maher\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\checks\urls.py", line 13, in check_url_config
    return check_resolver(resolver)
  File "C:\Users\Ahmed Maher\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\checks\urls.py", line 23, in check_resolver
    return check_method()
  File "C:\Users\Ahmed Maher\AppData\Local\Programs\Python\Python38\lib\site-packages\django\urls\resolvers.py", line 412, in check
    for pattern in self.url_patterns:
  File "C:\Users\Ahmed Maher\AppData\Local\Programs\Python\Python38\lib\site-packages\django\utils\functional.py", line 48, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "C:\Users\Ahmed Maher\AppData\Local\Programs\Python\Python38\lib\site-packages\django\urls\resolvers.py", line 598, in url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
  File "C:\Users\Ahmed Maher\AppData\Local\Programs\Python\Python38\lib\site-packages\django\utils\functional.py", line 48, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "C:\Users\Ahmed Maher\AppData\Local\Programs\Python\Python38\lib\site-packages\django\urls\resolvers.py", line 591, in urlconf_module
    return import_module(self.urlconf_name)
  File "C:\Users\Ahmed Maher\AppData\Local\Programs\Python\Python38\lib\importlib\__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 783, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "D:\Projects\مشاريع التخرج\BIS-Graduation-Project\BIS\BIS\urls.py", line 28, in <module>
    path("sole_proprietorship/" , include("sole_proprietorship.urls")) ,
  File "C:\Users\Ahmed Maher\AppData\Local\Programs\Python\Python38\lib\site-packages\django\urls\conf.py", line 34, in include        
    urlconf_module = import_module(urlconf_module)
  File "C:\Users\Ahmed Maher\AppData\Local\Programs\Python\Python38\lib\importlib\__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 783, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "D:\Projects\مشاريع التخرج\BIS-Graduation-Project\BIS\sole_proprietorship\urls.py", line 3, in <module>
    from . import views
  File "D:\Projects\مشاريع التخرج\BIS-Graduation-Project\BIS\sole_proprietorship\views.py", line 38, in <module>
    from django_renderpdf.views import PDFView
  File "C:\Users\Ahmed Maher\AppData\Local\Programs\Python\Python38\lib\site-packages\django_renderpdf\views.py", line 10, in <module>
    from django_renderpdf import helpers
  File "C:\Users\Ahmed Maher\AppData\Local\Programs\Python\Python38\lib\site-packages\django_renderpdf\helpers.py", line 13, in <module>
    from weasyprint import default_url_fetcher
  File "C:\Users\Ahmed Maher\AppData\Local\Programs\Python\Python38\lib\site-packages\weasyprint\__init__.py", line 322, in <module>
    from .css import preprocess_stylesheet  # noqa isort:skip
  File "C:\Users\Ahmed Maher\AppData\Local\Programs\Python\Python38\lib\site-packages\weasyprint\css\__init__.py", line 27, in <module>    from . import computed_values, counters, media_queries
  File "C:\Users\Ahmed Maher\AppData\Local\Programs\Python\Python38\lib\site-packages\weasyprint\css\computed_values.py", line 16, in <module>
    from ..text.ffi import ffi, pango, units_to_double
  File "C:\Users\Ahmed Maher\AppData\Local\Programs\Python\Python38\lib\site-packages\weasyprint\text\ffi.py", line 380, in <module>   
    gobject = _dlopen(
  File "C:\Users\Ahmed Maher\AppData\Local\Programs\Python\Python38\lib\site-packages\weasyprint\text\ffi.py", line 377, in _dlopen
    return ffi.dlopen(names[0])  # pragma: no cover
  File "C:\Users\Ahmed Maher\AppData\Local\Programs\Python\Python38\lib\site-packages\cffi\api.py", line 150, in dlopen
    lib, function_cache = _make_ffi_library(self, name, flags)
  File "C:\Users\Ahmed Maher\AppData\Local\Programs\Python\Python38\lib\site-packages\cffi\api.py", line 832, in _make_ffi_library
    backendlib = _load_backend_lib(backend, libname, flags)
  File "C:\Users\Ahmed Maher\AppData\Local\Programs\Python\Python38\lib\site-packages\cffi\api.py", line 827, in _load_backend_lib     
    raise OSError(msg)
OSError: cannot load library 'gobject-2.0-0': error 0x7e.  Additionally, ctypes.util.find_library() did not manage to locate a library 
called 'gobject-2.0-0'
Traceback (most recent call last):
  File "manage.py", line 22, in <module>
    main()
  File "manage.py", line 18, in main
    execute_from_command_line(sys.argv)
  File "C:\Users\Ahmed Maher\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\management\__init__.py", line 419, in execute_from_command_line
    utility.execute()
  File "C:\Users\Ahmed Maher\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\management\__init__.py", line 413, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "C:\Users\Ahmed Maher\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\management\base.py", line 367, in run_from_argv
    connections.close_all()
  File "C:\Users\Ahmed Maher\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\utils.py", line 213, in close_all      
  File "C:\Users\Ahmed Maher\AppData\Local\Programs\Python\Python38\lib\site-packages\django\utils\asyncio.py", line 19, in inner
    event_loop = asyncio.get_event_loop()
  File "C:\Users\Ahmed Maher\AppData\Local\Programs\Python\Python38\lib\asyncio\events.py", line 636, in get_event_loop

Exception ignored in: <function BaseEventLoop.__del__ at 0x000001687F273DC0>
Traceback (most recent call last):
  File "C:\Users\Ahmed Maher\AppData\Local\Programs\Python\Python38\lib\asyncio\base_events.py", line 656, in __del__
  File "C:\Users\Ahmed Maher\AppData\Local\Programs\Python\Python38\lib\asyncio\proactor_events.py", line 684, in close
  File "C:\Users\Ahmed Maher\AppData\Local\Programs\Python\Python38\lib\asyncio\proactor_events.py", line 752, in _close_self_pipe     
AttributeError: 'ProactorEventLoop' object has no attribute '_ssock'

(env) D:\Projects\مشاريع التخرج\BIS-Graduation-Project\BIS>
(env) D:\Projects\مشاريع التخرج\BIS-Graduation-Project\BIS>
(env) D:\Projects\مشاريع التخرج\BIS-Graduation-Project\BIS>
(env) D:\Projects\مشاريع التخرج\BIS-Graduation-Project\BIS>
(env) D:\Projects\مشاريع التخرج\BIS-Graduation-Project\BIS>py manage.py runserver
Watching for file changes with StatReloader
Performing system checks...

Exception in thread django-main-thread:
Traceback (most recent call last):
  File "C:\Users\Ahmed Maher\AppData\Local\Programs\Python\Python38\lib\threading.py", line 932, in _bootstrap_inner
    self.run()
  File "C:\Users\Ahmed Maher\AppData\Local\Programs\Python\Python38\lib\threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "C:\Users\Ahmed Maher\AppData\Local\Programs\Python\Python38\lib\site-packages\django\utils\autoreload.py", line 64, in wrapper 
    fn(*args, **kwargs)
  File "C:\Users\Ahmed Maher\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\management\commands\runserver.py", line 118, in inner_run
    self.check(display_num_errors=True)
  File "C:\Users\Ahmed Maher\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\management\base.py", line 419, in check
    all_issues = checks.run_checks(
  File "C:\Users\Ahmed Maher\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\checks\registry.py", line 76, in run_checks
    new_errors = check(app_configs=app_configs, databases=databases)
  File "C:\Users\Ahmed Maher\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\checks\urls.py", line 13, in check_url_config
    return check_resolver(resolver)
  File "C:\Users\Ahmed Maher\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\checks\urls.py", line 23, in check_resolver
    return check_method()
  File "C:\Users\Ahmed Maher\AppData\Local\Programs\Python\Python38\lib\site-packages\django\urls\resolvers.py", line 412, in check    
    for pattern in self.url_patterns:
  File "C:\Users\Ahmed Maher\AppData\Local\Programs\Python\Python38\lib\site-packages\django\utils\functional.py", line 48, in __get__ 
    res = instance.__dict__[self.name] = self.func(instance)
  File "C:\Users\Ahmed Maher\AppData\Local\Programs\Python\Python38\lib\site-packages\django\urls\resolvers.py", line 598, in url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
  File "C:\Users\Ahmed Maher\AppData\Local\Programs\Python\Python38\lib\site-packages\django\utils\functional.py", line 48, in __get__ 
    res = instance.__dict__[self.name] = self.func(instance)
  File "C:\Users\Ahmed Maher\AppData\Local\Programs\Python\Python38\lib\site-packages\django\urls\resolvers.py", line 591, in urlconf_module
    return import_module(self.urlconf_name)
  File "C:\Users\Ahmed Maher\AppData\Local\Programs\Python\Python38\lib\importlib\__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 783, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "D:\Projects\مشاريع التخرج\BIS-Graduation-Project\BIS\BIS\urls.py", line 28, in <module>
    path("sole_proprietorship/" , include("sole_proprietorship.urls")) ,
  File "C:\Users\Ahmed Maher\AppData\Local\Programs\Python\Python38\lib\site-packages\django\urls\conf.py", line 34, in include        
    urlconf_module = import_module(urlconf_module)
  File "C:\Users\Ahmed Maher\AppData\Local\Programs\Python\Python38\lib\importlib\__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 783, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "D:\Projects\مشاريع التخرج\BIS-Graduation-Project\BIS\sole_proprietorship\urls.py", line 3, in <module>
    from . import views
  File "D:\Projects\مشاريع التخرج\BIS-Graduation-Project\BIS\sole_proprietorship\views.py", line 38, in <module>
    from django_renderpdf.views import PDFView
  File "C:\Users\Ahmed Maher\AppData\Local\Programs\Python\Python38\lib\site-packages\django_renderpdf\views.py", line 10, in <module> 
    from django_renderpdf import helpers
  File "C:\Users\Ahmed Maher\AppData\Local\Programs\Python\Python38\lib\site-packages\django_renderpdf\helpers.py", line 13, in <module>
    from weasyprint import default_url_fetcher
  File "C:\Users\Ahmed Maher\AppData\Local\Programs\Python\Python38\lib\site-packages\weasyprint\__init__.py", line 322, in <module>   
    from .css import preprocess_stylesheet  # noqa isort:skip
  File "C:\Users\Ahmed Maher\AppData\Local\Programs\Python\Python38\lib\site-packages\weasyprint\css\__init__.py", line 27, in <module>    from . import computed_values, counters, media_queries
  File "C:\Users\Ahmed Maher\AppData\Local\Programs\Python\Python38\lib\site-packages\weasyprint\css\computed_values.py", line 16, in <module>
    from ..text.ffi import ffi, pango, units_to_double
  File "C:\Users\Ahmed Maher\AppData\Local\Programs\Python\Python38\lib\site-packages\weasyprint\text\ffi.py", line 380, in <module>
    gobject = _dlopen(
  File "C:\Users\Ahmed Maher\AppData\Local\Programs\Python\Python38\lib\site-packages\weasyprint\text\ffi.py", line 377, in _dlopen    
    return ffi.dlopen(names[0])  # pragma: no cover
  File "C:\Users\Ahmed Maher\AppData\Local\Programs\Python\Python38\lib\site-packages\cffi\api.py", line 150, in dlopen
    lib, function_cache = _make_ffi_library(self, name, flags)
  File "C:\Users\Ahmed Maher\AppData\Local\Programs\Python\Python38\lib\site-packages\cffi\api.py", line 832, in _make_ffi_library
    backendlib = _load_backend_lib(backend, libname, flags)
  File "C:\Users\Ahmed Maher\AppData\Local\Programs\Python\Python38\lib\site-packages\cffi\api.py", line 827, in _load_backend_lib     
    raise OSError(msg)
OSError: cannot load library 'gobject-2.0-0': error 0x7e.  Additionally, ctypes.util.find_library() did not manage to locate a library 
called 'gobject-2.0-0'
WhyNotHugo commented 2 years ago

weasyprint is failing to load gobject-2. Is it installed?

It seems that installing it on window it quite non-trivial, but there's some instructions here: https://doc.courtbouillon.org/weasyprint/v0.42.3/install.html#windows

See issues here if you have problems after following the above instructions: https://github.com/Kozea/WeasyPrint/issues?q=cannot+load+library+%27gobject-2.0-0%27%3A

WhyNotHugo commented 2 years ago

Actually, will leave open since the docs should point out that weasyprint's dependencies are required.

AhmedSalam22 commented 2 years ago

@WhyNotHugo I have another issue after install GTK3

Exception in thread django-main-thread:
Traceback (most recent call last):
  File "C:\Users\Ahmed Maher\AppData\Local\Programs\Python\Python38\lib\threading.py", line 932, in _bootstrap_inner
    self.run()
  File "C:\Users\Ahmed Maher\AppData\Local\Programs\Python\Python38\lib\threading.py", line 870, in run        
    self._target(*self._args, **self._kwargs)
  File "C:\Users\Ahmed Maher\AppData\Local\Programs\Python\Python38\lib\site-packages\django\utils\autoreload.py", line 64, in wrapper
    fn(*args, **kwargs)
  File "C:\Users\Ahmed Maher\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\management\commands\runserver.py", line 118, in inner_run
    self.check(display_num_errors=True)
  File "C:\Users\Ahmed Maher\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\management\base.py", line 419, in check
    all_issues = checks.run_checks(
  File "C:\Users\Ahmed Maher\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\checks\registry.py", line 76, in run_checks
    new_errors = check(app_configs=app_configs, databases=databases)
  File "C:\Users\Ahmed Maher\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\checks\urls.py", line 13, in check_url_config
    return check_resolver(resolver)
  File "C:\Users\Ahmed Maher\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\checks\urls.py", line 23, in check_resolver
    return check_method()
  File "C:\Users\Ahmed Maher\AppData\Local\Programs\Python\Python38\lib\site-packages\django\urls\resolvers.py", line 412, in check
    for pattern in self.url_patterns:
  File "C:\Users\Ahmed Maher\AppData\Local\Programs\Python\Python38\lib\site-packages\django\utils\functional.py", line 48, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "C:\Users\Ahmed Maher\AppData\Local\Programs\Python\Python38\lib\site-packages\django\urls\resolvers.py", line 598, in url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
  File "C:\Users\Ahmed Maher\AppData\Local\Programs\Python\Python38\lib\site-packages\django\utils\functional.py", line 48, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "C:\Users\Ahmed Maher\AppData\Local\Programs\Python\Python38\lib\site-packages\django\urls\resolvers.py", line 591, in urlconf_module
    return import_module(self.urlconf_name)
  File "C:\Users\Ahmed Maher\AppData\Local\Programs\Python\Python38\lib\importlib\__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 783, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "D:\Projects\مشاريع التخرج\BIS-Graduation-Project\BIS\BIS\urls.py", line 28, in <module>
    path("sole_proprietorship/" , include("sole_proprietorship.urls")) ,
  File "C:\Users\Ahmed Maher\AppData\Local\Programs\Python\Python38\lib\site-packages\django\urls\conf.py", line 34, in include
    urlconf_module = import_module(urlconf_module)
  File "C:\Users\Ahmed Maher\AppData\Local\Programs\Python\Python38\lib\importlib\__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 783, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "D:\Projects\مشاريع التخرج\BIS-Graduation-Project\BIS\sole_proprietorship\urls.py", line 3, in <module> 
    from . import views
  File "D:\Projects\مشاريع التخرج\BIS-Graduation-Project\BIS\sole_proprietorship\views.py", line 41, in <module>
    from django_weasyprint import WeasyTemplateResponseMixin
  File "C:\Users\Ahmed Maher\AppData\Local\Programs\Python\Python38\lib\site-packages\django_weasyprint\__init__.py", line 1, in <module>
    from .views import WeasyTemplateResponseMixin, WeasyTemplateView, WeasyTemplateResponse
  File "C:\Users\Ahmed Maher\AppData\Local\Programs\Python\Python38\lib\site-packages\django_weasyprint\views.py", line 1, in <module>
    import weasyprint
  File "C:\Users\Ahmed Maher\AppData\Local\Programs\Python\Python38\lib\site-packages\weasyprint\__init__.py", 
line 440, in <module>
    from .css import preprocess_stylesheet  # noqa isort:skip
  File "C:\Users\Ahmed Maher\AppData\Local\Programs\Python\Python38\lib\site-packages\weasyprint\css\__init__.py", line 30, in <module>
    from . import computed_values, media_queries
  File "C:\Users\Ahmed Maher\AppData\Local\Programs\Python\Python38\lib\site-packages\weasyprint\css\computed_values.py", line 18, in <module>
    from .. import text
  File "C:\Users\Ahmed Maher\AppData\Local\Programs\Python\Python38\lib\site-packages\weasyprint\text.py", line 259, in <module>
    pango = dlopen(ffi, 'pango-1.0', 'libpango-1.0-0', 'libpango-1.0.so',
  File "C:\Users\Ahmed Maher\AppData\Local\Programs\Python\Python38\lib\site-packages\weasyprint\text.py", line 254, in dlopen
    return ffi.dlopen(names[0])  # pragma: no cover
  File "C:\Users\Ahmed Maher\AppData\Local\Programs\Python\Python38\lib\site-packages\cffi\api.py", line 150, in dlopen
    lib, function_cache = _make_ffi_library(self, name, flags)
  File "C:\Users\Ahmed Maher\AppData\Local\Programs\Python\Python38\lib\site-packages\cffi\api.py", line 832, in _make_ffi_library
    backendlib = _load_backend_lib(backend, libname, flags)
  File "C:\Users\Ahmed Maher\AppData\Local\Programs\Python\Python38\lib\site-packages\cffi\api.py", line 827, in _load_backend_lib
    raise OSError(msg)
OSError: cannot load library 'pango-1.0': error 0x7e.  Additionally, ctypes.util.find_library() did not manage 
to locate a library called 'pango-1.0'