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

2

16

I am hoping to run my app without any problem, but I got this attached error. Could someone help or point me into the right direction as to why this is happening?

Traceback (most recent call last):
  File "/Users/andre.sitorus/Documents/GitHub/nexus/automation-api/app/main.py", line 4, in <module>
    from configurations import config  # noqa # pylint: disable=unused-import
  File "/Users/andre.sitorus/Documents/GitHub/nexus/automation-api/app/configurations/config.py", line 7, in <module>
    from google.cloud import secretmanager
  File "/Users/andre.sitorus/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/andre.sitorus/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/andre.sitorus/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/andre.sitorus/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/andre.sitorus/opt/miniconda3/envs/nexus/lib/python3.9/site-packages/google/api_core/gapic_v1/config.py", line 23, in <module>
    import grpc
  File "/Users/andre.sitorus/opt/miniconda3/envs/nexus/lib/python3.9/site-packages/grpc/__init__.py", line 22, in <module>
    from grpc import _compression
  File "/Users/andre.sitorus/opt/miniconda3/envs/nexus/lib/python3.9/site-packages/grpc/_compression.py", line 15, in <module>
    from grpc._cython import cygrpc
ImportError: dlopen(/Users/andre.sitorus/opt/miniconda3/envs/nexus/lib/python3.9/site-packages/grpc/_cython/cygrpc.cpython-39-darwin.so, 2): Symbol not found: _CFRelease
  Referenced from: /Users/andre.sitorus/opt/miniconda3/envs/nexus/lib/python3.9/site-packages/grpc/_cython/cygrpc.cpython-39-darwin.so
  Expected in: flat namespace
 in /Users/andre.sitorus/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
Gibrian answered 14/6, 2022 at 17:16 Comment(1)
Not enough info to give specific answer. Generally, dynamic library issues are often caused by mixing channels. We'd probably need to see a conda env export output to give more precise answer.Diametrically
A
39

Had the same issue; turned out it's because of the grpcio build. Doing this helped:

pip uninstall grpcio
conda install grpcio

(Make sure you use the conda-forge channel with conda; the community puts in work to make sure packages play well with M1/arm64)

Ambassadress answered 5/8, 2022 at 5:49 Comment(0)
G
13

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:
Garner answered 3/11, 2022 at 16:22 Comment(2)
This worked better for me than the other below from @Ambassadress (using conda) on macos M1Ritaritardando
This worked better than the accepted solutionRefuel

© 2022 - 2024 — McMap. All rights reserved.