xxyzz / WordDumb

A calibre plugin that generates Kindle Word Wise and X-Ray files for KFX, AZW3, MOBI and EPUB eBook.
https://xxyzz.github.io/WordDumb/
GNU General Public License v3.0
386 stars 19 forks source link

Create X-Ray error on ARM Mac #49

Closed chensiyue98 closed 2 years ago

chensiyue98 commented 2 years ago

Describe the bug

The following error occurs when attempting to create x-ray.

System Information

OS: MacOS 13.0 Beta calibre version: 6.1.0 Python version: 3.9.13 Plugin version: 3.23.1

Error message

calibre, version 6.1.0 (darwin, embedded-python: True)
Tonnerre de Brest!: An error occurred, please copy error message then report bug at GitHub.

Starting job: Generating X-Ray for Ethics: a very short introduction 
Job: "Generating X-Ray for Ethics: a very short introduction" failed with error: 
Traceback (most recent call last):
  File "calibre/gui2/threaded_jobs.py", line 82, in start_work
  File "calibre_plugins.worddumb.parse_job", line 147, in do_job
    run_subprocess(args, input_str)
  File "calibre_plugins.worddumb.utils", line 48, in run_subprocess
    return subprocess.run(
  File "subprocess.py", line 524, in run
subprocess.CalledProcessError: Command '['/opt/homebrew/bin/python3', '/Users/******/Library/Preferences/calibre/plugins/WordDumb.zip', 'BBIKAV6TKI', '/Users/******/Calibre 书库/Simon Blackburn/Ethics_ a very short introduction (29)/Ethics_ a very short introduction - Simon Blackburn.mobi', 'Ethics__a_very_short_introducti', '93c51c9f', 'en_core_web_lg', 'en', 'utf-8', '3.23.1', 'cn', '', 'MOBI', '1', '/Users/******/Library/Preferences/calibre/plugins/WordDumb.zip', '', '-x', '-s']' returned non-zero exit status 1.

Called with args: ((29, 'MOBI', '/Users/******/Calibre Library/Simon Blackburn/Ethics_ a very short introduction (29)/Ethics_ a very short introduction - Simon Blackburn.mobi', <calibre.ebooks.metadata.book.base.Metadata object at 0x1134d6c50>, {'spacy': 'en_core_web_', 'wiki': 'en', 'kaikki': 'English'}), False, True) {'notifications': <queue.Queue object at 0x1134d6dd0>, 'abort': <threading.Event object at 0x1134d6b00>, 'log': <calibre.utils.logging.GUILog object at 0x1134d6e60>} 
Traceback (most recent call last):
  File "/opt/homebrew/Cellar/python@3.9/3.9.13_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/opt/homebrew/Cellar/python@3.9/3.9.13_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/Users/******/Library/Preferences/calibre/plugins/WordDumb.zip/__main__.py", line 55, in <module>
  File "/Users/******/Library/Preferences/calibre/plugins/WordDumb.zip/parse_job.py", line 246, in create_files
  File "/Users/******/Library/Preferences/calibre/plugins/WordDumb.zip/parse_job.py", line 570, in load_spacy
  File "/Users/******/Library/Preferences/calibre/plugins/worddumb-libs-py3.9/spacy/__init__.py", line 6, in <module>
    from .errors import setup_default_warnings
  File "/Users/******/Library/Preferences/calibre/plugins/worddumb-libs-py3.9/spacy/errors.py", line 2, in <module>
    from .compat import Literal
  File "/Users/******/Library/Preferences/calibre/plugins/worddumb-libs-py3.9/spacy/compat.py", line 38, in <module>
    from thinc.api import Optimizer  # noqa: F401
  File "/Users/******/Library/Preferences/calibre/plugins/worddumb-libs-py3.9/thinc/api.py", line 2, in <module>
    from .initializers import normal_init, uniform_init, glorot_uniform_init, zero_init
  File "/Users/******/Library/Preferences/calibre/plugins/worddumb-libs-py3.9/thinc/initializers.py", line 4, in <module>
    from .backends import Ops
  File "/Users/******/Library/Preferences/calibre/plugins/worddumb-libs-py3.9/thinc/backends/__init__.py", line 7, in <module>
    from .ops import Ops
  File "/Users/******/Library/Preferences/calibre/plugins/worddumb-libs-py3.9/thinc/backends/ops.py", line 15, in <module>
    from .cblas import CBlas
  File "thinc/backends/cblas.pyx", line 1, in init thinc.backends.cblas
  File "/Users/******/Library/Preferences/calibre/plugins/worddumb-libs-py3.9/blis/__init__.py", line 3, in <module>
    from .cy import init
ImportError: dlopen(/Users/******/Library/Preferences/calibre/plugins/worddumb-libs-py3.9/blis/cy.cpython-39-darwin.so, 0x0002): tried: '/Users/******/Library/Preferences/calibre/plugins/worddumb-libs-py3.9/blis/cy.cpython-39-darwin.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e')), '/System/Volumes/Preboot/Cryptexes/OS/Users/******/Library/Preferences/calibre/plugins/worddumb-libs-py3.9/blis/cy.cpython-39-darwin.so' (no such file), '/Users/******/Library/Preferences/calibre/plugins/worddumb-libs-py3.9/blis/cy.cpython-39-darwin.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e'))

Reproduce steps

  1. Select a book
  2. Click Word Dump -> Create X-Ray
  3. Error message

Screenshots or videos

No response

chensiyue98 commented 2 years ago

I make a workaround by re-link my homebrew python version from 3.9 to 3.8. Is it possible to add a parameter in preferences that enables customized python path?

xxyzz commented 2 years ago

You need to delete the worddumb-libs-* folder and let the plugin reinstall dependencies in the next job. All the compiled packages are x86_64 on you mac before calibre 6 was released, as the error says: (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e'). You could still use older or X86_64 Python but you'll miss out the speed improvement of newer Python(3.10, 3.11) and 8x speed up from thinc-apple-ops.