allenai / pawls

Software that makes labeling PDFs easy.
https://pawls.apps.allenai.org
Apache License 2.0
380 stars 74 forks source link

Running PAWLS on MacOS M1 Machine #197

Open sanjanachin opened 1 year ago

sanjanachin commented 1 year ago

Hi!

I'm trying to use PAWLS to collect PDF annotations, but the pawls command is not working when I try to follow the installation on MacOS. Specifically, after running:

$ pawls

I get the following response:

Traceback (most recent call last):
  File "/opt/homebrew/bin/pawls", line 33, in <module>
    sys.exit(load_entry_point('pawls==0.0.1', 'console_scripts', 'pawls')())
  File "/opt/homebrew/bin/pawls", line 25, in importlib_load_entry_point
    return next(matches).load()
  File "/opt/homebrew/Cellar/python@3.10/3.10.9/Frameworks/Python.framework/Versions/3.10/lib/python3.10/importlib/metadata/__init__.py", line 171, in load
    module = import_module(match.group('module'))
  File "/opt/homebrew/Cellar/python@3.10/3.10.9/Frameworks/Python.framework/Versions/3.10/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/opt/homebrew/lib/python3.10/site-packages/pawls-0.0.1-py3.10.egg/pawls/__main__.py", line 3, in <module>
    from pawls import commands
  File "/opt/homebrew/lib/python3.10/site-packages/pawls-0.0.1-py3.10.egg/pawls/commands/__init__.py", line 1, in <module>
    from pawls.commands.preprocess import preprocess
  File "/opt/homebrew/lib/python3.10/site-packages/pawls-0.0.1-py3.10.egg/pawls/commands/preprocess.py", line 10, in <module>
    from pawls.preprocessors.pdfplumber import process_pdfplumber
  File "/opt/homebrew/lib/python3.10/site-packages/pawls-0.0.1-py3.10.egg/pawls/preprocessors/pdfplumber.py", line 4, in <module>
    import pdfplumber
  File "/opt/homebrew/lib/python3.10/site-packages/pdfplumber-0.7.6-py3.10.egg/pdfplumber/__init__.py", line 14, in <module>
    from .pdf import PDF
  File "/opt/homebrew/lib/python3.10/site-packages/pdfplumber-0.7.6-py3.10.egg/pdfplumber/pdf.py", line 9, in <module>
    from pdfminer.pdfdocument import PDFDocument
  File "/opt/homebrew/lib/python3.10/site-packages/pdfminer-20191125-py3.10.egg/pdfminer/pdfdocument.py", line 10, in <module>
    from Crypto.Cipher import ARC4
  File "/opt/homebrew/lib/python3.10/site-packages/pycryptodome-3.16.0-py3.10-macosx-12-arm64.egg/Crypto/Cipher/__init__.py", line 27, in <module>
    from Crypto.Cipher._mode_ecb import _create_ecb_cipher
  File "/opt/homebrew/lib/python3.10/site-packages/pycryptodome-3.16.0-py3.10-macosx-12-arm64.egg/Crypto/Cipher/_mode_ecb.py", line 35, in <module>
    raw_ecb_lib = load_pycryptodome_raw_lib("Crypto.Cipher._raw_ecb", """
  File "/opt/homebrew/lib/python3.10/site-packages/pycryptodome-3.16.0-py3.10-macosx-12-arm64.egg/Crypto/Util/_raw_api.py", line 309, in load_pycryptodome_raw_lib
    raise OSError("Cannot load native module '%s': %s" % (name, ", ".join(attempts)))
OSError: Cannot load native module 'Crypto.Cipher._raw_ecb': Not found '_raw_ecb.cpython-310-darwin.so', Cannot load '_raw_ecb.abi3.so': cannot load library '/opt/homebrew/lib/python3.10/site-packages/pycryptodome-3.16.0-py3.10-macosx-12-arm64.egg/Crypto/Util/../Cipher/_raw_ecb.abi3.so': dlopen(/opt/homebrew/lib/python3.10/site-packages/pycryptodome-3.16.0-py3.10-macosx-12-arm64.egg/Crypto/Util/../Cipher/_raw_ecb.abi3.so, 0x0002): tried: '/opt/homebrew/lib/python3.10/site-packages/pycryptodome-3.16.0-py3.10-macosx-12-arm64.egg/Crypto/Util/../Cipher/_raw_ecb.abi3.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e')), '/usr/local/lib/_raw_ecb.abi3.so' (no such file), '/usr/lib/_raw_ecb.abi3.so' (no such file), '/opt/homebrew/lib/python3.10/site-packages/pycryptodome-3.16.0-py3.10-macosx-12-arm64.egg/Crypto/Cipher/_raw_ecb.abi3.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e')), '/usr/local/lib/_raw_ecb.abi3.so' (no such file), '/usr/lib/_raw_ecb.abi3.so' (no such file).  Additionally, ctypes.util.find_library() did not manage to locate a library called '/opt/homebrew/lib/python3.10/site-packages/pycryptodome-3.16.0-py3.10-macosx-12-arm64.egg/Crypto/Util/../Cipher/_raw_ecb.abi3.so', Not found '_raw_ecb.so'

When I used the same installation procedure on a Ubuntu machine, everything worked normally, and I was able to use this process to add custom PDFs.

But, I am now unable to export any annotations because the pawls command is not working.

Any ideas?

Thanks!

soldni commented 1 year ago

@sanjanachin are you currently using an Apple Silicon Machine (e.g. M1 MacBook Pro)?

sanjanachin commented 1 year ago

@soldni Yes, I'm using an M1 Mac.

soldni commented 1 year ago

If you can, I would recommend managing your environment with conda, and installing pycrypto via conda install pycrypto.

On Jan 24, 2023 at 14:34:12, sanjanachin @.***> wrote:

@soldni https://github.com/soldni Yes, I'm using an M1 Mac.

— Reply to this email directly, view it on GitHub https://github.com/allenai/pawls/issues/197#issuecomment-1402780037, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA53OIVJAZZSUDOYXX7C553WUBKGJANCNFSM6AAAAAAUFP3HZI . You are receiving this because you were mentioned.Message ID: @.***>