无法在Apple M1芯片中为python django安装firebase-admin pip包



Apple M1 Chip System无法安装firebase-admin

系统配置

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

我使用下面的步骤为我的项目创建虚拟环境

  1. install virtualenv using pip install virtualenv
  2. virtualenv venv -p python3.x(任意选择)
  3. source /your_project/venv/bin/activate
  4. 您的venv将激活,然后您可以在pip
  5. 的帮助下安装需求

之后,我尝试安装firebase-adminpip install firebase-admin

下面出现错误
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('"'"'rn'"'"', '"'"'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.

如果尝试安装pip install boto3pip install django等等,包工作正常,只面对firebase admin的问题。

试着运行这个命令:

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

似乎grpc不支持M1 mac。

这里是相关的github问题:

  • https://github.com/firebase/firebase-admin-python/issues/530
  • https://github.com/googleapis/python-firestore/issues/285
  • https://github.com/grpc/grpc/issues/25082

你可以试试这个,因为这可能是问题:

首先,升级pip

pip3 install --upgrade pip

然后,更新安装工具:

python3 -m pip install --upgrade setuptools

最后,使用以下命令安装grpcio:

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

这些公认的答案似乎都不起作用,但这里的最上面的答案对我有用。如何在Apple M1硅笔记本电脑上安装GRPCIO ?

相关内容

  • 没有找到相关文章

最新更新