ahrm / sioyek

Sioyek is a PDF viewer with a focus on textbooks and research papers
https://sioyek.info/
GNU General Public License v3.0
7.15k stars 236 forks source link

Unable to launch commands (maybe architecture related) [MacOS, M1] #654

Open luca-san-git opened 1 year ago

luca-san-git commented 1 year ago

I am trying to add commands but I am unable to launch any of them. Using macOS Ventura 13.1 on a M1 MacbookPro

I think there is an error with the architecture version, I have tried

new_command _import_annotations python3 -m sioyek.import_annotations "%{sioyek_path}" "%{local_database}" "%{shared_database}" "%{file_path}" and the result is

QString::arg: Argument missing: python3 -m sioyek.import_annotations "%{sioyek_path}" "%{local_database}" "%{shared_database}" "%{file_path}", /Users/x/Documents/Sioyek_scripts/plan.pdf
Traceback (most recent call last):
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/Users/x/Library/Python/3.9/lib/python/site-packages/sioyek/import_annotations.py", line 2, in <module>
    from .sioyek import Sioyek, clean_path
  File "/Users/x/Library/Python/3.9/lib/python/site-packages/sioyek/sioyek.py", line 5, in <module>
    import regex
  File "/Users/x/Library/Python/3.9/lib/python/site-packages/regex/__init__.py", line 1, in <module>
    from .regex import *
  File "/Users/x/Library/Python/3.9/lib/python/site-packages/regex/regex.py", line 421, in <module>
    import regex._regex_core as _regex_core
  File "/Users/x/Library/Python/3.9/lib/python/site-packages/regex/_regex_core.py", line 21, in <module>
    import regex._regex as _regex
ImportError: dlopen(/Users/x/Library/Python/3.9/lib/python/site-packages/regex/_regex.cpython-39-darwin.so, 0x0002): tried: '/Users/x/Library/Python/3.9/lib/python/site-packages/regex/_regex.cpython-39-darwin.so' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64')), '/System/Volumes/Preboot/Cryptexes/OS/Users/x/Library/Python/3.9/lib/python/site-packages/regex/_regex.cpython-39-darwin.so' (no such file), '/Users/x/Library/Python/3.9/lib/python/site-packages/regex/_regex.cpython-39-darwin.so' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64'))

however, adding arch -x86_64 in front of the python3 command did not help (this was a suggestion I found on the internet, I am not familiar with M1 architecture... )

So I tried with something simple:

new_command _write cp "%1" "%1_a"

this is the result:

cp: "/Users/x/Documents/Sioyek_scripts/plan.pdf": No such file or directory However, I clearly have the file, as it can be seen from

x@LS-DOSX145 ~ % ls "/Users/x/Documents/Sioyek_scripts/plan.pdf"
/Users/x/Documents/Sioyek_scripts/plan.pdf

I don't know what else I can do, I would love any sort of guidance Thanks!

ahrm commented 1 year ago

Does this work? :

new_command _import_annotations python3 -m sioyek.import_annotations '%{sioyek_path}' '%{local_database}' '%{shared_database}' '%{file_path}'
luca-san-git commented 1 year ago

It does not


QString::arg: Argument missing: python3 -m sioyek.import_annotations '%{sioyek_path}' '%{local_database}' '%{shared_database}' '%{file_path}', /Users/x/Documents/Sioyek_scripts/plan.pdf
Traceback (most recent call last):
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/Users/x/Library/Python/3.9/lib/python/site-packages/sioyek/import_annotations.py", line 2, in <module>
    from .sioyek import Sioyek, clean_path
  File "/Users/x/Library/Python/3.9/lib/python/site-packages/sioyek/sioyek.py", line 5, in <module>
    import regex
  File "/Users/x/Library/Python/3.9/lib/python/site-packages/regex/__init__.py", line 1, in <module>
    from .regex import *
  File "/Users/x/Library/Python/3.9/lib/python/site-packages/regex/regex.py", line 421, in <module>
    import regex._regex_core as _regex_core
  File "/Users/x/Library/Python/3.9/lib/python/site-packages/regex/_regex_core.py", line 21, in <module>
    import regex._regex as _regex
ImportError: dlopen(/Users/x/Library/Python/3.9/lib/python/site-packages/regex/_regex.cpython-39-darwin.so, 0x0002): tried: '/Users/x/Library/Python/3.9/lib/python/site-packages/regex/_regex.cpython-39-darwin.so' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64')), '/System/Volumes/Preboot/Cryptexes/OS/Users/x/Library/Python/3.9/lib/python/site-packages/regex/_regex.cpython-39-darwin.so' (no such file), '/Users/x/Library/Python/3.9/lib/python/site-packages/regex/_regex.cpython-39-darwin.so' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64'))
ahrm commented 1 year ago

Does using arch -arm64 before the command work?

luca-san-git commented 1 year ago

No, exact same error

luca-san-git commented 1 year ago

Update, might be related? Only some (basic) commands work:

Touch does not work

new_command _touch touch "%1_delete"
> touch: "/Users/x/Documents/Sioyek_scripts/plan.pdf_delete": No such file or directory

Echo works

new_command _echo echo "%1_delete"
> "/Users/x/Documents/Sioyek_scripts/plan.pdf_delete"
ahrm commented 1 year ago

Does it work when you run sioyek from the command line (instead of running it from the GUI)?

luca-san-git commented 1 year ago

No, I usually run sioyek from command line and what I am reporting is the common behaviour (also, I don't know how to see console messages when running it from GUI)

If you are instead asking to run a "sioyek + command_to_be_interpreted" from the command line, I don't know how to do it.

luca-san-git commented 1 year ago

Any update on the matter? I would love to help if there is anything I can do

ahrm commented 1 year ago

Unfortunately I don't have a mac machine so I can't help you right now, maybe someone else with a mac can help?

luca-san-git commented 1 year ago

I will try to test it on a Mac without M1 processor, to see if there is any difference

sbryngelson commented 1 year ago

Maybe related https://github.com/ahrm/sioyek-python-extensions/issues/19

ahrm commented 1 year ago

Does this solution help: https://github.com/ahrm/sioyek/issues/771#issuecomment-1715436107 ?

sbryngelson commented 1 year ago

Unfortunately no, more context @ https://github.com/ahrm/sioyek-python-extensions/issues/19