wyfo / apischema

JSON (de)serialization, GraphQL and JSON schema generation using Python typing.

Home Page:https://wyfo.github.io/apischema/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Installation fails on Mac M1

AnderUstarroz opened this issue · comments

commented

Installation fails on new Mac with M1 chips throwing the following error:

    from apischema.serialization import serialize
  File "/Users/my_user/.pyenv/versions/3.9.9/envs/cubist-games-manager/lib/python3.9/site-packages/apischema/serialization/__init__.py", line 34, in <module>
    from apischema.serialization.methods import (
ImportError: dlopen(/Users/my_user/.pyenv/versions/3.9.9/envs/cubist-games-manager/lib/python3.9/site-packages/apischema/serialization/methods.cpython-39-darwin.so, 0x0002): tried: '/Users/my_user/.pyenv/versions/3.9.9/envs/cubist-games-manager/lib/python3.9/site-packages/apischema/serialization/methods.cpython-39-darwin.so' 
(mach-o file, but is an incompatible architecture (have (x86_64), need (arm64e)))

uninstall the library (pip uninstall apischema) then install it using arch arm64 arch -arm64 pip install apischema

@AnderUstarroz Did @mbutnaruy: comment solve your issue? I don't have a Mac M1 to test it myself.

@wyfo This issue seems to be long gone, feel free to close this (tested on M1)

FYI, this is still an issue, I'm getting:

Traceback (most recent call last):
  File "/Users/mkramb/test/test/bla.py", line 2, in <module>
    from kubecrd import schemabase
  File "/Users/mkramb/test/.venv/lib/python3.10/site-packages/kubecrd/__init__.py", line 1, in <module>
    from .schemabase import KubeResourceBase
  File "/Users/mkramb/test/.venv/lib/python3.10/site-packages/kubecrd/schemabase.py", line 5, in <module>
    from apischema import serialize
  File "/Users/mkramb/test/.venv/lib/python3.10/site-packages/apischema/__init__.py", line 43, in <module>
    from .deserialization import deserialization_method, deserialize
  File "/Users/mkramb/test/.venv/lib/python3.10/site-packages/apischema/deserialization/__init__.py", line 40, in <module>
    from apischema.deserialization.methods import (
ImportError: dlopen(/Users/mkramb/test/.venv/lib/python3.10/site-packages/apischema/deserialization/methods.cpython-310-darwin.so, 0x0002): tried: '/Users/mkramb/test/.venv/lib/python3.10/site-packages/apischema/deserialization/methods.cpython-310-darwin.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64')), '/System/Volumes/Preboot/Cryptexes/OS/Users/mkramb/test/.venv/lib/python3.10/site-packages/apischema/deserialization/methods.cpython-310-darwin.so' (no such file), '/Users/mkramb/test/.venv/lib/python3.10/site-packages/apischema/deserialization/methods.cpython-310-darwin.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64'))

@AnderUstarroz how did you fix the issue? thanks

@mkramb I have no problems on M1.

Looks like your case is an indirect import through a few other packages. Could this be a part of your problem? Not sure.
Are you able to pip install apischema and just test importing it directly? It works instantly for me.

If it does work, then doing pip cache purge and reinstalling might solve it. I've also read that arch -arm64 pip install <whatever> might help.