pythonpython-3.xcondaapple-m1grpc-python

Apple M1 - Symbol not found: _CFRelease while running Python app


I wanna run my app without any problem, but I got this attached error. Could someone help or point me in the right direction regarding why this is happening?

Traceback (most recent call last):
  File "/Users/enchant3dmango/Documents/GitHub/nexus/automation-api/app/main.py", line 4, in <module>
    from configurations import config  # noqa # pylint: disable=unused-import
  File "/Users/enchant3dmango/Documents/GitHub/nexus/automation-api/app/configurations/config.py", line 7, in <module>
    from google.cloud import secretmanager
  File "/Users/enchant3dmango/opt/miniconda3/envs/nexus/lib/python3.9/site-packages/google/cloud/secretmanager.py", line 20, in <module>
    from google.cloud.secretmanager_v1 import SecretManagerServiceClient
  File "/Users/enchant3dmango/opt/miniconda3/envs/nexus/lib/python3.9/site-packages/google/cloud/secretmanager_v1/__init__.py", line 24, in <module>
    from google.cloud.secretmanager_v1.gapic import secret_manager_service_client
  File "/Users/enchant3dmango/opt/miniconda3/envs/nexus/lib/python3.9/site-packages/google/cloud/secretmanager_v1/gapic/secret_manager_service_client.py", line 25, in <module>
    import google.api_core.gapic_v1.client_info
  File "/Users/enchant3dmango/opt/miniconda3/envs/nexus/lib/python3.9/site-packages/google/api_core/gapic_v1/__init__.py", line 18, in <module>
    from google.api_core.gapic_v1 import config
  File "/Users/enchant3dmango/opt/miniconda3/envs/nexus/lib/python3.9/site-packages/google/api_core/gapic_v1/config.py", line 23, in <module>
    import grpc
  File "/Users/enchant3dmango/opt/miniconda3/envs/nexus/lib/python3.9/site-packages/grpc/__init__.py", line 22, in <module>
    from grpc import _compression
  File "/Users/enchant3dmango/opt/miniconda3/envs/nexus/lib/python3.9/site-packages/grpc/_compression.py", line 15, in <module>
    from grpc._cython import cygrpc
ImportError: dlopen(/Users/enchant3dmango/opt/miniconda3/envs/nexus/lib/python3.9/site-packages/grpc/_cython/cygrpc.cpython-39-darwin.so, 2): Symbol not found: _CFRelease
  Referenced from: /Users/enchant3dmango/opt/miniconda3/envs/nexus/lib/python3.9/site-packages/grpc/_cython/cygrpc.cpython-39-darwin.so
  Expected in: flat namespace
 in /Users/enchant3dmango/opt/miniconda3/envs/nexus/lib/python3.9/site-packages/grpc/_cython/cygrpc.cpython-39-darwin.so

I'm running this in Apple M1.

I already upgraded pip and setuptools before installing all the requirements in my virtual environment using conda. Here is my python, pip, and setuptools version:

python 3.9.12
pip 21.2.4
setuptools 62.4.0

Solution

  • I was able to get around the problem by rebuilding grpcio from source like this:

    pip uninstall grpcio
    export GRPC_PYTHON_LDFLAGS=" -framework CoreFoundation"
    pip install grpcio --no-binary :all: