New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
OSError: cannot load library 'gobject-2.0': error 0x7e. #971
Comments
Did you install the/a GTK3-Runtime? |
Yes, I installed GTK3. Is gobject related to GTK?
On Oct 17, 2019 2:51 AM, Tontyna <notifications@github.com> wrote:
Did you install the/a GTK3-Runtime?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub<#971?email_source=notifications&email_token=AGJMWFY4P3E2UNPJNQY5U7TQO6SIJA5CNFSM4JBRWDE2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEBOJBAI#issuecomment-542937217>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AGJMWF6Q2H44IBER7WAVOWLQO6SIJANCNFSM4JBRWDEQ>.
|
Yes. So. As always when it comes to "OSError cannot load library" on Windows it's a matter of The fact that weasyprint.text complains about Please run the following command in the shell where you start WeasyPrint and check the output.
|
I am not the original poster, but I am having the exact same issue (I also have anaconda installed). Something else I can check? |
I checked the folder that the path was pointing to.... I think I found the issue, however I don't understand why it happened. let me know if you have any thoughts. Thanks! |
My (main) dll's are named Isn't there a way to tell Anaconda's environment what paths it should include? |
Had a closer look at Anaconda. Anaconda is just Python with some comfort. @tyoung88 -- did you run the python command that prints the paths from the same command prompt or shell where your WeasyPrint fails with OSError? I'm quite sure you didn't. I'm quite sure you run WeasyPrint from an Anaconda Prompt or similar that activates Anaconda's environment -- and pushes the Anaconda search paths (including a folder called There mus be an activation script, probably a """
sitecustomize.py
================
To ensure the correct GTK3 Runtime
- To activate the GTK for Anaconda and all its environments:
put the file into **sys.base_prefix**,
i.e. the path where Anaconda's master python.exe is located.
i.e. your Anaconda install directory
- To activate the GTK only in a dedicated environment:
put the file into the **./Lib/site-packages** folder of that
environemt
"""
import os
# insert the GTK3 Runtime folder at the beginning
GTK_FOLDER = r'C:\Program Files\GTK3-Runtime Win64\bin'
os.environ['PATH'] = GTK_FOLDER + os.pathsep + os.environ.get('PATH', '') No need to rename anything 😁 Be aware that some IDE's try to be helpful and insert folders they consider useful into the |
I just wanted to update after such a complete answer @Tontyna . I am still unsure why the dlls could not be found properly... |
I have a hypothesis, implying Anaconda's |
I had a similar issue and it turned out the GTK2 dlls were getting in the way of the GTK3 ones. |
I ran into the same issue in conda and was only able to resolve it, by installing the gtk-libraries from msys2 . While using the gtk+ 64bit windows installer I got popups on import of weasyprint that said:
(don't know how to translate THAT - who is localizing techy error messages?) And some other similiar errors. The initial error said
but that isn't actual the error occuring on windows. If I run
And that points to a similiar (and old) issue with cffi: So I am guessing something in conda isn't compatible with the way how the gtk-libraries in the 64bit windows installer are compiled. But on the other hand I may be entirely wrong. I have no clue about compiling anything anywhere. Long story short: Using msys2 on conda resolved the issue for me. |
Sounds reasonable. |
the sitecustomize.py route worked for me. Just added it to my script before importing weasyprint |
I'm having the same problem with GTK+3 DLLs installed with MSYS2 and copied to an embedded Python 3.8 distribution. Process Monitor shows that Python looks for
But that had no effect. |
I got to this page and fixed the problem on my side by a few trials: The problem root cause on my end is due to multiple libgobject-2.0-0.dll on my system. On your anaconda command prompt, run "where libgobject-2.0-0.dll". My first output is: C:\Program Files (x86)\GtkSharp\2.12\bin\libgobject-2.0-0.dll Since C:\Program Files (x86)\GtkSharp\2.12\bin\ has a higher priority in path variable list, so the wrong dll was found and loaded incorrectly. To fix this, go to edit variable page and edit "path" of system variable, then make C:\Program Files\GTK3-Runtime Win64\bin\ to have a higher position. Reopen a new command prompt. If your "where" output shows: C:\Program Files\GTK3-Runtime Win64\bin\libgobject-2.0-0.dll Then you are all set. Hope this can help. |
Closing, as following the documentation steps or the hints in these comments should be enough to solve this issue. |
After checking if installed GTK-3 and Env-Params contains "C:\Program Files\GTK3-Runtime Win64\bin" . I switch to the 64-bit version. It's work now. You have to build the project in Python 64-bit version, not 32-bit. |
I was having this same error. I managed to fix (windows) putting gtk in the path above all others (for both user and system). GTK - https://github.com/tschoonj/GTK-for-Windows-Runtime-Environment-Installer/releases |
Hi, Can you help mi with the same issue in django? I Did the same as you mentioned (windows) putting gtk in the path above all others (for both user and system). But no luck. Did you do something like this? Thanks
|
And if you’re interested, you can test the current beta version. With Python 3.8+, you shouldn’t have to play with the |
Yes I did the same. But still this error 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' |
Hi, I am using Python 3.9.5, Django==3.2.7, weasyprint==53.4 (tried lower version 53.0 but no luck), and gtk3-runtime-3.24.29-2021-04-29-ts-win64.exe. I did as @clebemachado suggested with paths. I restarted computer. Uninstall weasyprint and install from beginning. tired to set paths like this: |
Using
It will only work with version 54.0b1, and the default value is already set, so you don’t even have to set it manually. Installing this version will probably solve your problem (using |
Now I have weasyprint==54.0b1. Also tried this command ` C:\Users\LLL\sqlite-tools-win32-x86-3360000 Thanks |
I’ll try to be clear. With Python 3.8+, for any version of WeasyPrint, With Python 3.8+ and WeasyPrint 54.0b1:
So, if you have the
This code is needed if you actually want to transform
The GTK+ installer installs everything, including Pango. |
Did everything as you said. no luck. Opened new issue #1526 |
Hi, I managed to solve the problem upgrading django version then close and reopen project. Thanks for helping. |
Hey guys update i had the same problem with a Django. project and deleting the virtual environment then setting up a new one worked for me |
hey, guys am facing the same challenge here I have tried all the options above but still in vain the |
Did you carefully follow the steps of the documentation? What’s your OS? |
@liZe |
Do you have the 64-bit version of Windows? Otherwise, I don’t know why it doesn’t work. |
I had to use win 11 64-bit to clear the error |
@Tontyna thank you so much,,you are life saver.. |
I made a django website for windows 10 with the weasyprint library. Also installed GTK+ for Windows Runtime Environment (мversion 3). The same errors were thrown. |
I followed the instructions for installing on Windows with Python 64 bit. I'm using an Anaconda installation but "conda install weasyprint" did not find a package, so I used "pip". I'm getting the error below when trying to test weasyprint. After seeing the error, I tried to manually install "glib" using "conda". It installed. But, did not fix the issue.
C:\Users\david>python -m weasyprint http://weasyprint.org weasyprint.pdf
Traceback (most recent call last):
File "C:\Users\david\Anaconda3\lib\runpy.py", line 183, in _run_module_as_main
mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
File "C:\Users\david\Anaconda3\lib\runpy.py", line 142, in _get_module_details
return get_module_details(pkg_main_name, error)
File "C:\Users\david\Anaconda3\lib\runpy.py", line 109, in get_module_details
import(pkg_name)
File "C:\Users\david\Anaconda3\lib\site-packages\weasyprint_init.py", line 440, in
from .css import preprocess_stylesheet # noqa isort:skip
File "C:\Users\david\Anaconda3\lib\site-packages\weasyprint\css_init.py", line 30, in
from . import computed_values, media_queries
File "C:\Users\david\Anaconda3\lib\site-packages\weasyprint\css\computed_values.py", line 17, in
from .. import text
File "C:\Users\david\Anaconda3\lib\site-packages\weasyprint\text.py", line 257, in
'libgobject-2.0.dylib')
File "C:\Users\david\Anaconda3\lib\site-packages\weasyprint\text.py", line 253, in dlopen
return ffi.dlopen(names[0]) # pragma: no cover
File "C:\Users\david\Anaconda3\lib\site-packages\cffi\api.py", line 146, in dlopen
lib, function_cache = _make_ffi_library(self, name, flags)
File "C:\Users\david\Anaconda3\lib\site-packages\cffi\api.py", line 828, in _make_ffi_library
backendlib = _load_backend_lib(backend, libname, flags)
File "C:\Users\david\Anaconda3\lib\site-packages\cffi\api.py", line 823, in _load_backend_lib
raise OSError(msg)
OSError: cannot load library 'gobject-2.0': error 0x7e. Additionally, ctypes.util.find_library() did not manage to locate a library called 'gobject-2.0'
The text was updated successfully, but these errors were encountered: