Isolate PyMuPDF from other libraries; issues when PyMuPDF is loaded with other libraries like GdkPixbuf #3493
-
Hey all. A small example. In [1]: import fitz
In [2]: d = fitz.open("sample/alice-in-wonderland.epub")
In [3]: d[0].get_pixmap().save("without-library.png") Now load In [1]: from gi.repository import GdkPixbuf
<ipython-input-1-e18be571bbf2>:1: PyGIWarning: GdkPixbuf was imported without specifying a version first. Use gi.require_version('GdkPixbuf', '2.0') before import to ensure that the right version gets loaded.
from gi.repository import GdkPixbuf
In [2]: import fitz
In [3]: d = fitz.open("sample/alice-in-wonderland.epub")
In [4]: d[0].get_pixmap().save("with-library.png") I know this is not a problem of My primary question would be if anybody has an idea why this issue occurs? Am I looking at it in the wrong direction? Thanks in advance! Sorry if it has been already asked. |
Beta Was this translation helpful? Give feedback.
Replies: 8 comments 8 replies
-
Looks like this is something that has already been explored a lot like in #85, #1396, #133 etc. MuPDF error: library error: jpeg error: Wrong JPEG library version: library is 62, caller expects 90 |
Beta Was this translation helpful? Give feedback.
-
I have found However, installing from system package manager is a temporary solution as, if I want to keep my app cross-platform, then I would have to get the official PyMuPDF builds anyway. One way I thought of is to make the PyMuPDF logic a separate process and use a shared memory to communicate with the GUI. However I'm not sure how the latency will be in this case. Other solution would be to build PyMuPDF (and in turn MuPDF) from source with patches to make it use the JPEG libraries GdkPixbuf is using. @JorjMcKie @rk700 any thoughts or help on how it can be taken forward? (Extremely sorry for tagging, but I feel like you both have more expertise in this issue than me, apologies again!) |
Beta Was this translation helpful? Give feedback.
-
I would have hoped that MuPDF would see the library code that it was built with, before any system-wide library, so i'm not sure what's going on here. How are you installing/building PyMuPDF? Are you using a pre-built wheel from pypi.org? |
Beta Was this translation helpful? Give feedback.
-
Ok that's good to know, thanks. I'm so far unable to reproduce the problem.
A couple if things come to mind:
I'm rather clutching at straws here, but that might at least verify some things that we need to be certain about. |
Beta Was this translation helpful? Give feedback.
-
One other thing to try is to swap the import of
This may well avoid the problem, but even if does i wouldn't be surprised if attempts to use |
Beta Was this translation helpful? Give feedback.
-
I've managed to reproduce the problem. It looks like linking MuPDF with BTW to answer to your earlier question about building PyMuPDF with a local MuPDF, see: https://pymupdf.readthedocs.io/en/latest/installation.html#build-and-install-from-a-local-pymupdf-source-tree. Note that we always build MuPDF in a way that is correct for PyMuPDF (for example always build as a shared-library), one cannot currently simply specify pre-built MuPDF libraries. Also see comments at top of |
Beta Was this translation helpful? Give feedback.
-
This will be fixed in the next release - we will be building MuPDF with |
Beta Was this translation helpful? Give feedback.
-
Fixed in 1.24.6. |
Beta Was this translation helpful? Give feedback.
This will be fixed in the next release - we will be building MuPDF with
-bSymbolic
.