2

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.

FBB
  • 326
  • 1
  • 12
  • 1
    This is the bug report on grpcio project: https://github.com/grpc/grpc/issues/25082. it is currently closed as fixed, but based on the comments it's still not working for many developers. You might want to try some of the workarounds discussed in that thread. – Hiranya Jayathilaka Jun 29 '21 at 19:40
  • You could open terminal under Rosetta 2 emulation and see if that works for you. Solution here https://stackoverflow.com/questions/39477023/error-mach-o-but-wrong-architecture-after-installing-anaconda-on-mac# – enkash Apr 25 '22 at 13:04

1 Answers1

4

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.
FBB
  • 326
  • 1
  • 12
  • 1
    I commented on the bug report here what they do and that it worked for me back in January: https://github.com/grpc/grpc/issues/25082#issuecomment-754565768. – Jeppe Fihl-Pearson Jul 10 '21 at 17:45