简体   繁体   中英

Unable to install firebase-admin pip package for python django in Apple M1 chip

Unable to install firebase-admin in Apple M1 Chip System

System Configuration

System OS: macOS Bigsur(11.2.2) 
chip: Apple M1
python version: 3.9.2 
Pip Version: 20.0.1 
Djnago: 3.1.7 

I create virtual env for my project using below steps

  1. install virtualenv using pip install virtualenv
  2. virtualenv venv -p python3.x (whichever you want)
  3. source /your_project/venv/bin/activate
  4. your venv will activate and then you can install requirements with the help of pip

After this i try to install firebase-admin pip install firebase-admin and i get error like below

File "/private/var/folders/2l/g855nfq11js0q9s9dc9ygk000000gn/T/pip-build-env-aapo6r5y/normal/lib/python3.9/site-packages/cffi/api.py", line 48, in __init__
        import _cffi_backend as backend
    ImportError: dlopen(/private/var/folders/2l/g855nfq11js0q9s9dc9ygk000000gn/T/pip-build-env-aapo6r5y/normal/lib/python3.9/site-packages/_cffi_backend.cpython-39-darwin.so, 2): no suitable image found.  Did find:
        /private/var/folders/2l/g855nfq11js0q9s9dc9ygk000000gn/T/pip-build-env-aapo6r5y/normal/lib/python3.9/site-packages/_cffi_backend.cpython-39-darwin.so: mach-o, but wrong architecture
        /private/var/folders/2l/g855nfq11js0q9s9dc9ygk000000gn/T/pip-build-env-aapo6r5y/normal/lib/python3.9/site-packages/_cffi_backend.cpython-39-darwin.so: mach-o, but wrong architecture


 File "/private/var/folders/2l/g855nfq11js0q9s9dc9ygk000000gn/T/pip-install-yurwgn0k/grpcio_2bb9c0d1fcb8462591aa5aa845bcb162/src/python/grpcio/_parallel_compile_patch.py", line 54, in _compile_single_file
      self._compile(obj, src, ext, cc_args, extra_postargs, pp_opts)
    File "/private/var/folders/2l/g855nfq11js0q9s9dc9ygk000000gn/T/pip-install-yurwgn0k/grpcio_2bb9c0d1fcb8462591aa5aa845bcb162/src/python/grpcio/commands.py", line 250, in new_compile
      return old_compile(obj, src, ext, cc_args, extra_postargs,
    File "/opt/homebrew/Cellar/python@3.9/3.9.2_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/unixccompiler.py", line 120, in _compile
      raise CompileError(msg)
  distutils.errors.CompileError: command '/usr/bin/clang' failed with exit code 1
  
  ----------------------------------------
  ERROR: Failed building wheel for grpcio

ERROR: Command errored out with exit status 1: /Volumes/DATA-D/user/Project/project_name/Api/fitquid/venv/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/2l/g855nfq11js0q9s9dc9ygk000000gn/T/pip-install-yurwgn0k/grpcio_2bb9c0d1fcb8462591aa5aa845bcb162/setup.py'"'"'; __file__='"'"'/private/var/folders/2l/g855nfq11js0q9s9dc9ygk000000gn/T/pip-install-yurwgn0k/grpcio_2bb9c0d1fcb8462591aa5aa845bcb162/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/2l/g855nfq11js0q9s9dc9ygk000000gn/T/pip-record-jmxgwm9r/install-record.txt --single-version-externally-managed --compile --install-headers /Volumes/DATA-D/Drashti/Project/Fitquid/Api/webapis/fitquid/venv/include/site/python3.9/grpcio Check the logs for full command output.

If try to insall pip install boto3 , pip install django etc. packages are working fine facing issue only with the firebase admin.

Try running this command:

arch -arch x86_64 /usr/bin/python3 -m pip install firebase-admin

It seems that grpc is not providing support for M1 macs.

Here are related github issues:

You can try this since this could be the issue:

First, upgrade pip

pip3 install --upgrade pip

Then, update the setup tools:

python3 -m pip install --upgrade setuptools

At last, install grpcio using:

pip3 install --no-cache-dir  --force-reinstall -Iv grpcio==<version_number>

None of these accepted answers seem to work, but the top answer here works for me. How can I install GRPCIO on an Apple M1 Silicon laptop?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM