Search code examples
pythonfirebasefirebase-adminapple-m1apple-silicon

Install of python firebase-admin on Apple Silicon/M1 fails, grpico fails


The python firebase admin SDK isn't installing on Apple Silicon/M1. I've tried fixes in other posts here and on Github and they haven't worked. It's unclear to me if they work for anyone.

Installation Problem

The command pip install firebase-admin fails when it tries the setup script for the grpico package, which is a dependency of firebase.

I've tried the install with python 3.8.2, 3.9.4, and 3.9.5. All the versions failed. I've tried it inside a venv and globally, both failed.

My understanding of what's going on so far is:

  1. grpico is a dependency of firebase-admin (version 5.0.0), so pip install firebase-admin will try to install grpico (version 1.38.0)
  2. grpico is only compiled for x86, so upon trying the setup steps for grpico, something (pip maybe) starts running a bunch of clang commands, attempting to compile a version for arm.
  3. Some part of the compile fails and spits out a crazy looking error.
ERROR: Command errored out with exit status 1: /Users/brown/Developer/parse-tools/env/bin/python -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] ...

My setup:

  • Big Sur 11.4
  • Python 3.9.5 (installed with homebrew) in a venv
  • pip 21.1.3
  • firebase-admin 5.0.0
  • grpico 1.38.0

If someone has a working fix, please explain how it works. I'm not a huge fan of pasting random commands into the terminal without understanding what they do.


Solution

  • Success - Simple but Mysterious

    After reading every crazy guide on how to install grpcio, I was able to get it working with only two steps.

    1. Set 2 environment variables to tell the setup script to do something different. Run the following commands in terminal:

    export GRPC_PYTHON_BUILD_SYSTEM_OPENSSL=1

    export GRPC_PYTHON_BUILD_SYSTEM_ZLIB=1

    What do these ENV vars do? Who knows. No one has bothered to explain or communicate around this issue at all. Classic.

    1. Run pip3 install firebase-admin. This worked for me.