Skip to content
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

release 1.23.0 not MacOS-arm64 compatible #2613

Closed
pjaol opened this issue Aug 23, 2023 · 17 comments
Closed

release 1.23.0 not MacOS-arm64 compatible #2613

pjaol opened this issue Aug 23, 2023 · 17 comments

Comments

@pjaol
Copy link

pjaol commented Aug 23, 2023

Please provide all mandatory information!

Using os x Ventura 13.4.1

poetry add pymypdf 

installs fine however when running you receive :

ImportError: dlopen(/Users/patrick/Projects/XXX/env/lib/python3.11/site-packages/fitz/_fitz.so, 0x0002): 
tried: '/Users/patrick/Projects/XXX/env/lib/python3.11/site-packages/fitz/_fitz.so' 
(mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64')), '/System/Volumes/Preboot/Cryptexes/OS/Users/patrick/Projects/XXX/env/lib/python3.11/site-packages/fitz/_fitz.so' (no such file), 
'/Users/patrick/Projects/XXX/env/lib/python3.11/site-packages/fitz/_fitz.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64')

backing down to

poetry add pymupdf==1.22.5

restores a working version

@julian-smith-artifex-com
Copy link
Collaborator

Thanks for reporting this.

Can you do pip install pymupdf instead?

In 1.23.0, the PyMuPDF wheel lists a new wheel PyMuPDFb as a requirement. Pip copes with this, installing both wheels automatically.

I'm not familiar with what poetry add does, perhaps it has an option to install such dependencies automatically? If not, you should be able to make things work by asking for both wheels explicitly, with something like poetry add pymypdfb pymypdf.

[Using two wheels in this way saves space on pypi.org, because we end up with just one PyMuPDFb wheel (containing the large MuPDF binaries) per OS.]

@bdonkey
Copy link

bdonkey commented Aug 23, 2023

I've tried pip install pymypdf and have run into the same problems. Had to back down to pip install pymupdf==1.22.5.
Also tried installing both pymupdfb and pymupdf but same ARCH error.

@julian-smith-artifex-com
Copy link
Collaborator

julian-smith-artifex-com commented Aug 23, 2023

This is odd, it works fine on other platforms. It looks like something may be installing a PyMuPDFb wheel for the wrong architecture. Or possibly we are not cross-compiling correctly when building macos-arm64 wheels.

If you could you do the following, it might allow us to figure out what's going on.

  • Make sure your pip is up to date with python -m pip install -U pip.
  • Clean up your venv with: pip uninstall PyMuPDF PuMuPDFb.
  • Run pip install -vv PyMuPDF | tee out and attach the complete file out to this issue.

@JoshJarabek7
Copy link

JoshJarabek7 commented Aug 23, 2023

Can confirm I am also having this issue.

Did a pip cache purge, deleted the venv, tried install fitz on its own, etc.

For pip install -vv PyMuPDF | tee out

Using pip 23.2.1 from /Users/josh/PARAKEET/BACK/.venv/lib/python3.11/site-packages/pip (python 3.11)
Non-user install because user site-packages disabled
Created temporary directory: /private/var/folders/wm/gl_n9_990fsdtz72dh5wm0bh0000gn/T/pip-build-tracker-_zpxdbl3
Initialized build tracking at /private/var/folders/wm/gl_n9_990fsdtz72dh5wm0bh0000gn/T/pip-build-tracker-_zpxdbl3
Created build tracker: /private/var/folders/wm/gl_n9_990fsdtz72dh5wm0bh0000gn/T/pip-build-tracker-_zpxdbl3
Entered build tracker: /private/var/folders/wm/gl_n9_990fsdtz72dh5wm0bh0000gn/T/pip-build-tracker-_zpxdbl3
Created temporary directory: /private/var/folders/wm/gl_n9_990fsdtz72dh5wm0bh0000gn/T/pip-install-xwc_x9ae
Created temporary directory: /private/var/folders/wm/gl_n9_990fsdtz72dh5wm0bh0000gn/T/pip-ephem-wheel-cache-8h1owpjr
Requirement already satisfied: PyMuPDF in ./.venv/lib/python3.11/site-packages (1.23.0)
Requirement already satisfied: PyMuPDFb==1.23.0 in ./.venv/lib/python3.11/site-packages (from PyMuPDF) (1.23.0)
Created temporary directory: /private/var/folders/wm/gl_n9_990fsdtz72dh5wm0bh0000gn/T/pip-unpack-itwxwvvf
Remote version of pip: 23.2.1
Local version of pip:  23.2.1
Was pip installed by pip? True
Removed build tracker: '/private/var/folders/wm/gl_n9_990fsdtz72dh5wm0bh0000gn/T/pip-build-tracker-_zpxdbl3'

@julian-smith-artifex-com
Copy link
Collaborator

It looks like some binaries within PyMuPDF 1.23.0-*macosx_11_0_arm64.whl wheels have been built incorrectly with a native x86_64 compiler instead of a cross compiler that targets arm64.

Apologies for this. We should be able to make a fixed release soon.

@julian-smith-artifex-com
Copy link
Collaborator

I've have a test wheel that may fix the problem.

The wheel is for MacOS, arm64 and Python-3.11.

It has been uploaded to test.pypi.org, and can be tested with:

pip uninstall --yes pymupdf
pip install -i https://test.pypi.org/simple pymupdf

Please let me know whether this works for you.

@julian-smith-artifex-com
Copy link
Collaborator

We've made a new release, PyMuPDF-1.23.1, which hopefully fixes this issue.

But we are currently unable to test MacOS arm64 wheels directly, so if people here could report how they get on with the new release, that would be very much appreciated.

@bdonkey
Copy link

bdonkey commented Aug 25, 2023

Here is Claude summary of my testing:

Summary: Getting an architecture mismatch error when trying to import PyMuPDF on M1 Mac

Repro steps:

  1. Created a new virtualenv (.venv) on my M1 Mac
  2. Tried installing PyMuPDF via:
    1. pip uninstall --yes pymupdf
    2. pip install -i https://test.pypi.org/simple pymupdf
  3. Also tried installing latest 1.23.1 release via pip install pymupdf
  4. Tested with pymudf-utilities/OCR/tesseract2.py

Error:

Both installation methods produce the same import error:

Traceback (most recent call last):
  File "/Users/scottschmidt/scottdev/PyMuPDF-Utilities/_ssdev/OCR/tesseract2.py", line 22, in <module>
    import fitz
  File "/Users/scottschmidt/scottdev/PyMuPDF-Utilities/.venv/lib/python3.10/site-packages/fitz/__init__.py", line 22, in <module>
    from fitz.fitz import *
  File "/Users/scottschmidt/scottdev/PyMuPDF-Utilities/.venv/lib/python3.10/site-packages/fitz/fitz.py", line 14, in <module>
    from . import _fitz
ImportError: dlopen(/Users/scottschmidt/scottdev/PyMuPDF-Utilities/.venv/lib/python3.10/site-packages/fitz/_fitz.so, 0x0002): tried: '/Users/scottschmidt/scottdev/PyMuPDF-Utilities/.venv/lib/python3.10/site-packages/fitz/_fitz.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64')), '/System/Volumes/Preboot/Cryptexes/OS/Users/scottschmidt/scottdev/PyMuPDF-Utilities/.venv/lib/python3.10/site-packages/fitz/_fitz.so' (no such file), '/Users/scottschmidt/scottdev/PyMuPDF-Utilities/.venv/lib/python3.10/site-packages/fitz/_fitz.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64'))

Environment details:

  • M1 Mac
  • Python 3.10 virtualenv

Attaching pip install log and screenshot showing architecture mismatch.
Screenshot 2023-08-24 at 17 45 31
pymmupdfPipTee.txt

Claude was better summarizing than my first attempt :)

@julian-smith-artifex-com
Copy link
Collaborator

Thanks for checking this, i'll carry on investigating what's going wrong.

@Aidenren1215
Copy link

I also encountered this issue, hopefully can solve it soon.

@julian-smith-artifex-com
Copy link
Collaborator

julian-smith-artifex-com commented Aug 26, 2023

I've made some progress i think. This wheel works for me on a macos-arm64 gcc cfarm machine:

http://ghostscript.com/~julian/PyMuPDF-1.23.1-cp39-none-macosx_11_0_arm64.whl

(I only have a wheel for Python-3.9 at the moment, more on Monday.)

@julian-smith-artifex-com
Copy link
Collaborator

julian-smith-artifex-com commented Aug 27, 2023

Here's a second test wheel now, for Python-3.11 on macos-arm64:

https://ghostscript.com/~julian/PyMuPDF-1.23.1-cp311-none-macosx_11_0_arm64.whl

(To test it, download to local directory and install with pip install PyMuPDF-1.23.1-cp311-none-macosx_11_0_arm64.whl.)

Note that currently i only have access to Python-3.9 on macos-arm64, so this wheel is untested.

@julian-smith-artifex-com julian-smith-artifex-com changed the title release 1.23.0 not arm64 compatible release 1.23.0 not MacOS-arm64 compatible Aug 27, 2023
@qcgm1978
Copy link

I meet some problems when import. At last install the latest pre-release version resolve it. pip install PyMuPDF==1.23.2rc1

@julian-smith-artifex-com
Copy link
Collaborator

Fixed in release 1.23.2.

@bdonkey
Copy link

bdonkey commented Aug 28, 2023

Yes. Thank you. This seems to fix the ARCH error. However, when I run 1.23.2 against pymupdf-utilities/OCR/tesseract2.py I receive the error:

Traceback (most recent call last):
  File "/Users/scottschmidt/scottdev/PyMuPDF-Utilities/_ssdev/OCR/tesseract2.py", line 75, in <module>
    new_text = sb + get_tessocr(page, s["bbox"]) + sa
  File "/Users/scottschmidt/scottdev/PyMuPDF-Utilities/_ssdev/OCR/tesseract2.py", line 48, in get_tessocr
    ocrpdf = fitz.open("pdf", pix.pdfocr_tobytes())
  File "/Users/scottschmidt/scottdev/PyMuPDF-Utilities/.venv/lib/python3.10/site-packages/fitz/fitz.py", line 7414, in pdfocr_tobytes
    self.pdfocr_save(bio, compress=compress, language=language, tessdata=tessdata)
  File "/Users/scottschmidt/scottdev/PyMuPDF-Utilities/.venv/lib/python3.10/site-packages/fitz/fitz.py", line 7392, in pdfocr_save
    return _fitz.Pixmap_pdfocr_save(self, filename, compress, language, tessdata)
RuntimeError: No OCR support in this build

Does 1.23.2 not support OCR? I could run this file against 1.22.

@cbm755
Copy link
Contributor

cbm755 commented Aug 29, 2023

Not sure "+1"s are useful here, but this fixes my macOS arm64 builds, thanks for quick response.

Downstream reference: https://gitlab.com/plom/plom/-/merge_requests/2217/

cbm755 added a commit to plomgrading/plom that referenced this issue Sep 2, 2023
@julian-smith-artifex-com
Copy link
Collaborator

However, when I run 1.23.2 against pymupdf-utilities/OCR/tesseract2.py I receive the error:

RuntimeError: No OCR support in this build

This is fixed in PyMuPDF-1.23.3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants