版本:grpcio=1.14.0
先说结论,执行以下步骤解决:
python3 -m pip install --upgrade -i https://pypi.tuna.tsinghua.edu.cn/simple setuptools
pip3 install --no-cache-dir --force-reinstall -i https://pypi.tuna.tsinghua.edu.cn/simple -Iv grpcio==1.40.0
解决前遇到的报错信息:
creating None
creating None/var
creating None/var/folders
creating None/var/folders/dd
creating None/var/folders/dd/q2kqqlbx7ls6r9dz4ywsjnn40000gn
creating None/var/folders/dd/q2kqqlbx7ls6r9dz4ywsjnn40000gn/T
creating None/var/folders/dd/q2kqqlbx7ls6r9dz4ywsjnn40000gn/T/tmplfv591p1
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -iwithsysroot/System/Library/Frameworks/System.framework/PrivateHeaders -iwithsysroot/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/Headers -arch arm64 -arch x86_64 -Werror=implicit-function-declaration -I/Users/blue/code/github/thingsboard-gateway/venv/include -I/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/Headers -c /var/folders/dd/q2kqqlbx7ls6r9dz4ywsjnn40000gn/T/tmplfv591p1/a.c -o None/var/folders/dd/q2kqqlbx7ls6r9dz4ywsjnn40000gn/T/tmplfv591p1/a.o
/var/folders/dd/q2kqqlbx7ls6r9dz4ywsjnn40000gn/T/tmplfv591p1/a.c:2:10: fatal error: 'Python.h' file not found
#include <Python.h>
^~~~~~~~~~
1 error generated.
Could not find <Python.h>. This could mean the following:
* You're on Ubuntu and haven't run `apt-get install python3-dev`.
* You're on RHEL/Fedora and haven't run `yum install python3-devel` or
`dnf install python3-devel` (make sure you also have redhat-rpm-config
installed)
* You're on Mac OS X and the usual Python framework was somehow corrupted
(check your environment variables or try re-installing?)
* You're on Windows and your Python installation was somehow corrupted
(check your environment variables or try re-installing?)
Traceback (most recent call last):
File "/Users/blue/code/github/thingsboard-gateway/venv/lib/python3.8/site-packages/setuptools/_distutils/unixccompiler.py", line 186, in _compile
self.spawn(compiler_so + cc_args + [src, '-o', obj] + extra_postargs)
File "/private/var/folders/dd/q2kqqlbx7ls6r9dz4ywsjnn40000gn/T/pip-install-y_rm53hj/grpcio_ddf3b4cb9c7b403793ab646e6c088fc8/src/python/grpcio/_spawn_patch.py", line 54, in _commandfile_spawn
_classic_spawn(self, command)
File "/Users/blue/code/github/thingsboard-gateway/venv/lib/python3.8/site-packages/setuptools/_distutils/ccompiler.py", line 1007, in spawn
spawn(cmd, dry_run=self.dry_run, **kwargs)
File "/Users/blue/code/github/thingsboard-gateway/venv/lib/python3.8/site-packages/setuptools/_distutils/spawn.py", line 70, in spawn
raise DistutilsExecError(
distutils.errors.DistutilsExecError: command '/usr/bin/clang' failed with exit code 1