Gabriel Herndon
Gabriel Herndon

Reputation: 158

On Apple M1, grpc/Google-Api Import Error:

Situation:

I'm trying to set up my SQLAlchemy database and run it locally. I use the google api for its vision module, so I can analyze text off of pictures.

Currently I had to switch from an old 2013 macbook to a new 2020 macbook with the m1 chip. I try to run my local environment but receive the following error.

ERROR:

File "/Users/gabriel/Desktop/PROJECT_NAME/src/main.py", line 3, in <module>
    import actions
  File "/Users/gabriel/Desktop/PROJECT_NAME/src/actions.py", line 3, in <module>
    import utils
  File "/Users/gabriel/Desktop/PROJECT_NAME/src/utils.py", line 5, in <module>
    import google.cloud.vision_v1 as vision
  File "/Users/gabriel/.local/share/virtualenvs/PROJECT_NAME/lib/python3.10/site-packages/google/cloud/vision_v1/__init__.py", line 20, in <module>
    from .services.image_annotator import ImageAnnotatorClient as IacImageAnnotatorClient
  File "/Users/gabriel/.local/share/virtualenvs/PROJECT_NAME/lib/python3.10/site-packages/google/cloud/vision_v1/services/image_annotator/__init__.py", line 16, in <module>
    from .client import ImageAnnotatorClient
  File "/Users/gabriel/.local/share/virtualenvs/PROJECT_NAME/lib/python3.10/site-packages/google/cloud/vision_v1/services/image_annotator/client.py", line 25, in <module>
    from google.api_core import gapic_v1  # type: ignore
  File "/Users/gabriel/.local/share/virtualenvs/PROJECT_NAME/lib/python3.10/site-packages/google/api_core/gapic_v1/__init__.py", line 16, in <module>
    from google.api_core.gapic_v1 import config
  File "/Users/gabriel/.local/share/virtualenvs/PROJECT_NAME/lib/python3.10/site-packages/google/api_core/gapic_v1/config.py", line 23, in <module>
    import grpc
  File "/Users/gabriel/.local/share/virtualenvs/PROJECT_NAME/lib/python3.10/site-packages/grpc/__init__.py", line 22, in <module>
    from grpc import _compression
  File "/Users/gabriel/.local/share/virtualenvs/PROJECT_NAME/lib/python3.10/site-packages/grpc/_compression.py", line 15, in <module>
    from grpc._cython import cygrpc
ImportError: dlopen(/Users/gabriel/.local/share/virtualenvs/PROJECT_NAME/lib/python3.10/site-packages/grpc/_cython/cygrpc.cpython-310-darwin.so, 0x0002): tried: '/Users/gabriel/.local/share/virtualenvs/PROJECT_NAME/lib/python3.10/site-packages/grpc/_cython/cygrpc.cpython-310-darwin.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e')), '/usr/lib/cygrpc.cpython-310-darwin.so' (no such file)

Hypothesis:

I believe it does have to do with trying to get the universal binary version in my dependencies, but at this point, I have no idea how link them correctly or if I even have the right package.

Specs:

Dependencies:

Tried Solutions:

Upvotes: 6

Views: 6917

Answers (1)

MrPrules
MrPrules

Reputation: 91

Run the following commands from within your shell (or from within your virtual environment)

pip install --no-binary :all: grpcio --ignore-installed
pip install --no-binary :all: grpcio-tools --ignore-installed

You can find more info from this comment made here for the Github Issue

Upvotes: 7

Related Questions