Closed Keou0007 closed 3 years ago
Can you try it with just cairo
instead of weasyprint in the environment? gobject-2.0 shouldn't be a direct dependency of weasyprint but rather cairo.
Edit: The full traceback would also be helpful in finding whether this is because of weasyprint or cairo.
Trying with just cairo now. The full traceback is
$ python -c "import weasyprint"
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/Users/shannon/opt/miniconda3/envs/weasyprint/lib/python3.6/site-packages/weasyprint/__init__.py", line 469, in <module>
from .css import preprocess_stylesheet # noqa isort:skip
File "/Users/shannon/opt/miniconda3/envs/weasyprint/lib/python3.6/site-packages/weasyprint/css/__init__.py", line 27, in <module>
from . import computed_values, counters, media_queries
File "/Users/shannon/opt/miniconda3/envs/weasyprint/lib/python3.6/site-packages/weasyprint/css/computed_values.py", line 15, in <module>
from .. import text
File "/Users/shannon/opt/miniconda3/envs/weasyprint/lib/python3.6/site-packages/weasyprint/text.py", line 259, in <module>
'libgobject-2.0.dylib')
File "/Users/shannon/opt/miniconda3/envs/weasyprint/lib/python3.6/site-packages/weasyprint/text.py", line 255, in dlopen
return ffi.dlopen(names[0]) # pragma: no cover
File "/Users/shannon/opt/miniconda3/envs/weasyprint/lib/python3.6/site-packages/cffi/api.py", line 150, in dlopen
lib, function_cache = _make_ffi_library(self, name, flags)
File "/Users/shannon/opt/miniconda3/envs/weasyprint/lib/python3.6/site-packages/cffi/api.py", line 832, in _make_ffi_library
backendlib = _load_backend_lib(backend, libname, flags)
File "/Users/shannon/opt/miniconda3/envs/weasyprint/lib/python3.6/site-packages/cffi/api.py", line 827, in _load_backend_lib
raise OSError(msg)
OSError: cannot load library 'gobject-2.0': dlopen(gobject-2.0, 2): image not found. Additionally, ctypes.util.find_library() did not manage to locate a library called 'gobject-2.0'
This works fine
conda create -n cairo python=3.8 cairo pycairo
conda activate cairo
python -c "import cairo"
Hmm ok then it's something else. Did you install everything through conda? Because I can find some other issues like this but it was primarily because parts were installed not through conda but homebrew etc.
yeah everything should be installed via conda. I do have homebrew on my system and that probably has a python install, but I've not had any conflicts between them before. Weasyprint had been working just fine for me. Last time I used it successfully was about two weeks ago. Not sure what I did that broke it, but I suspect conda update --all
Not completely sure about that because I have the same setup and cannot reproduce the error. What kind of paths do you have on your system?
python -c "import os; print(*os.environ['PATH'].split(os.pathsep), sep='\n')"
/Users/shannon/opt/miniconda3/bin
/Users/shannon/opt/miniconda3/condabin
/opt/local/bin
/opt/local/sbin
/usr/local/bin
/usr/bin
/bin
/usr/sbin
/sbin
/Library/TeX/texbin
/Applications/Little Snitch.app/Contents/Components
/opt/X11/bin
/Library/Apple/usr/bin
/Library/Frameworks/Mono.framework/Versions/Current/Commands
/usr/local/git/bin
Did you run that in the environment? Because I have an environment-specific path first.
sorry, I didn't
/Users/shannon/opt/miniconda3/envs/weasyprint/bin
/Users/shannon/opt/miniconda3/bin
/Users/shannon/opt/miniconda3/condabin
/opt/local/bin
/opt/local/sbin
/usr/local/bin
/usr/bin
/bin
/usr/sbin
/sbin
/Library/TeX/texbin
/Applications/Little Snitch.app/Contents/Components
/opt/X11/bin
/Library/Apple/usr/bin
/Library/Frameworks/Mono.framework/Versions/Current/Commands
/usr/local/git/bin
Ok that looks exactly like mine - strange. Updating all does change the environment but then shouldn't really affect the individual components again.
The only thing I can think of is installing gtk3 directly (conda install -c conda-forge gtk3
) as suggested here: https://github.com/Kozea/WeasyPrint/issues/971
yeah I already tried that, as well as any other glib things I could find, before I posted the issue. I'm really run out of ideas here.
Mine is under '/usr/local/lib/libgobject-2.0.dylib'
. Is this empty for you?
yup
$ ls /usr/local/lib/libg*
/usr/local/lib/libgcc_s.1.dylib /usr/local/lib/libgdbm.a /usr/local/lib/libgdbm_compat.4.dylib /usr/local/lib/libgdbm_compat.dylib /usr/local/lib/libgraphite2.3.dylib
/usr/local/lib/libgdbm.6.dylib /usr/local/lib/libgdbm.dylib /usr/local/lib/libgdbm_compat.a /usr/local/lib/libgraphite2.3.2.1.dylib /usr/local/lib/libgraphite2.dylib
hmmm. I just did conda install glib
in that environment and that seems to have fixed it. I'm SURE I tried that before...
Haha just wanted to ask that. Ok then it's a missing dependency.
Ok that's a conda error because libglib
should've installed that.
Edit: It's just run_constrained, I'll open an issue.
@liZe Do you know where the glib
dependency is from? And is there a minimum version?
If it's really required, I'd just add it to the meta.yaml.
@liZe Do you know where the
glib
dependency is from? And is there a minimum version? If it's really required, I'd just add it to the meta.yaml.
Isn’t libgobject-2.0.dylib
supposed to be provided by libglib
(that was already installed, probably as a dependency of Cairo)?
Isn’t
libgobject-2.0.dylib
supposed to be provided bylibglib
(that was already installed, probably as a dependency of Cairo)?
Yes and there‘s probably something wrong there: https://github.com/conda-forge/glib-feedstock/issues/104
This was just as a preliminary fix until then but it’s also probably fine to just wait and keep the issue open until then.
Yes and there‘s probably something wrong there: conda-forge/glib-feedstock#104
OK
This was just as a preliminary fix until then but it’s also probably fine to just wait and keep the issue open until then.
Adding the dependency with a comment linked to the issue is a possible workaround for now.
Issue:
Recently weasyprint stopped importing for me with the error:
I wasn't sure if it was something I changed, so I tried going back to basics. With a brand new installation of miniconda:
I still get the OSError. Any ideas?
Environment (
conda list
):Details about
conda
and system (conda info
):