yuce / pyswip

PySwip is a Python-Prolog interface that enables querying SWI-Prolog in your Python programs.
https://pyswip.org
MIT License
482 stars 98 forks source link

Compatibility with Mac M1 chip #134

Closed celinehocquette closed 2 years ago

celinehocquette commented 2 years ago

Hi,

I am having a mismatch of architecture when installing Pyswip as per the error message below:

Traceback (most recent call last):

  File "/Users/celtte/miniconda3/envs/my_env/lib/python3.9/site-packages/pyswip/__init__.py", line 29, in <module>

    from pyswip.prolog import Prolog

  File "/Users/celtte/miniconda3/envs/my_env/lib/python3.9/site-packages/pyswip/prolog.py", line 28, in <module>

    from pyswip.core import *

  File "/Users/celtte/miniconda3/envs/my_env/lib/python3.9/site-packages/pyswip/core.py", line 572, in <module>

    _lib = CDLL(_path, mode=RTLD_GLOBAL)

  File "/Users/celtte/miniconda3/envs/my_env/lib/python3.9/ctypes/__init__.py", line 382, in __init__

    self._handle = _dlopen(self._name, mode)

OSError: dlopen(/opt/homebrew/Cellar/swi-prolog/8.4.1/libexec/lib/swipl/lib/arm64-darwin/libswipl.dylib, 10): no suitable image found.  Did find:

    /opt/homebrew/Cellar/swi-prolog/8.4.1/libexec/lib/swipl/lib/arm64-darwin/libswipl.dylib: mach-o, but wrong architecture

    /opt/homebrew/Cellar/swi-prolog/8.4.1/libexec/lib/swipl/lib/arm64-darwin/libswipl.8.4.1.dylib: mach-o, but wrong architecture

I am using a Apple M1 chip which may cause the incompatibility. I have install Rosetta 2 already. I have tried following advice from https://github.com/explosion/spaCy/discussions/9561 but this has not solved the issue. I am using Python 3.9.7 with 64 bit architecture and SWI-Prolog version 8.4.1. I have tried resolving the incompatibility by trying different Python versions from https://www.python.org/downloads/macos/, especially Intel builds, or installing it with brew but no luck. I have also built the dev version of SWI or tried to install it with brew. Would you please have any suggestion for which python / swi-prolog to use or how to resolve the incompatibility?

I thank you in advance for any advice you may have!

Céline

AmrSol commented 2 years ago

Hi Céline,

I am having the same problem. I tried everything you mentioned and it didn't work either. I also installed the x86 build for SWI-PROLOG and Pyswip for x86 (Intel) and it would give me this error:

ValueError: not enough values to unpack (expected 2, got 1)

I am not sure what to do... Using swi-prolog and pyswip will be crucial for my research. I don't want to return this M1 MacBook because of how great it is at everything else. I hope someone can give us a solution.

celinehocquette commented 2 years ago

Hi Amr,

A solution to resolve the incompatibility of architecture is to use a Linux virtual Machine. Softwares such as Parallel are compatible with M1 chips, which is what I have been using since.

Best,

Céline

AmrSol commented 2 years ago

Hi Céline, You are amazing! Thank you so much. I was seriously considering alternative computers. I will add to this thread once I have found another solution. I tried Windows 11 (ARM) but that didn't work either. For some reason, Linux is working. I have no idea why...

For anyone wondering what I did to make the process slightly easier:

Warm regards, Amr

allComputableThings commented 2 years ago

Virtual Box or VMWare are also an option.

Are Parallels OSes portable to VMWare format? Or even out of Mac-land?

On Thu, Feb 3, 2022 at 12:13 PM Amr Soliman @.***> wrote:

Hi Céline, You are amazing! Thank you so much. I was seriously considering alternative computers. I will add to this thread once I have found another solution. I tried Windows 11 (ARM) but that didn't work either. For some reason, Linux is working. I have no idea why...

For anyone wondering what I did to make the process slightly easier:

  • Through Parallels, I installed Linux Ubuntu that was provided.
  • I installed VSCode and anaconda (I've never used Linux before so installing them was confusing and took trial and error)
  • I installed SWI-Prolog stable. This was the exact link. I followed their instructions one step at a time. https://www.swi-prolog.org/build/PPA.html
  • Through VSCode's jupyternotebooks I ran !pip3 install pyswip
  • I ran my code and voila, it worked!

Warm regards, Amr

— Reply to this email directly, view it on GitHub https://github.com/yuce/pyswip/issues/134#issuecomment-1029360856, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB3QJLBOJZTYAAD3F7SRNODUZLOWPANCNFSM5JWJJESQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>

celinehocquette commented 2 years ago

Virtual Box is not compatible with M1 chips, I am not sure about VMWare

yuce commented 2 years ago

A contributor updated https://github.com/yuce/pyswip/blob/master/INSTALL.md#macos-m1 for M1 Macs. Closing this issue for now, but feel free to reopen it if the instructions don't work.