首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >‘3安装grpcio`’在阿尔卑斯Linux上失败

‘3安装grpcio`’在阿尔卑斯Linux上失败
EN

Stack Overflow用户
提问于 2022-05-22 08:04:27
回答 1查看 1K关注 0票数 1

我在我的Mac (12.3.1)上使用Alpine并尝试运行pip3 install grpcio,但是这个命令总是失败的。

我试过这里的信息,但直到现在都没有用。

无法使用pip安装grpcio安装grpcio ->升级到最新的setuptools https://github.com/grpc/grpc/issues/24390 ->运行export GRPC_PYTHON_BUILD_SYSTEM_OPENSSL=1export GRPC_PYTHON_BUILD_SYSTEM_ZLIB=1

Step

  1. 使用此Dockerfile生成图像。

Dockerfile

代码语言:javascript
复制
FROM alpine:latest
COPY src /root/src # Please think this is empty. I don't use any files in this directory until now.
WORKDIR /root/src

RUN set -x \
    && apk update \
    && apk add build-base \
    && apk add python3 py3-pip python3-dev \
    && pip3 install --no-cache --upgrade pip setuptools \
    && pip3 install wheel
  1. 使用docker run进入图像。
  2. 运行pip3 list以检查已安装的内容。
代码语言:javascript
复制
~/src # pip3 list
Package            Version
------------------ ---------
appdirs            1.4.4
CacheControl       0.12.10
certifi            2020.12.5
charset-normalizer 2.0.7
colorama           0.4.4
contextlib2        21.6.0
distlib            0.3.3
distro             1.6.0
html5lib           1.1
idna               3.3
lockfile           0.12.2
msgpack            1.0.2
ordered-set        4.0.2
packaging          20.9
pep517             0.12.0
pip                22.1.1
progress           1.6
pyparsing          2.4.7
requests           2.26.0
retrying           1.3.3
setuptools         62.3.2
six                1.16.0
toml               0.10.2
tomli              1.2.2
urllib3            1.26.7
webencodings       0.5.1
wheel              0.37.1
  1. 运行pip3 install grpcio

此错误消息太长,无法在此问题中写入。请查看Google文档以获得完整的消息。https://docs.google.com/document/d/1ATyMCA0vRAsxfDquByeWh7cE7InhPCG6bDsgtDEG2Ls/edit?usp=sharing https://docs.google.com/document/d/19erFzIcB2zCDbCklyeOGDVNUBTf6I8oW4B-sNWuO6Zk/edit?usp=sharing

错误消息(最后一部分)

代码语言:javascript
复制
(There are messages before this part. Please check Google Docs.)
      gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -g -fno-semantic-interposition -g -fno-semantic-interposition -g -fno-semantic-interposition -DTHREAD_STACK_SIZE=0x100000 -fPIC -D_WIN32_WINNT=1536 -DGRPC_XDS_USER_AGENT_NAME_SUFFIX=\"Python\" -DGRPC_XDS_USER_AGENT_VERSION_SUFFIX=\"1.46.3\" -DGPR_BACKWARDS_COMPATIBILITY_MODE=1 -DHAVE_CONFIG_H=1 -DGRPC_ENABLE_FORK_SUPPORT=1 "-DPyMODINIT_FUNC=extern \"C\" __attribute__((visibility (\"default\"))) PyObject*" -DGRPC_POSIX_FORK_ALLOW_PTHREAD_ATFORK=1 -Isrc/python/grpcio -Iinclude -I. -Ithird_party/abseil-cpp -Ithird_party/address_sorting/include -Ithird_party/cares/cares/include -Ithird_party/cares -Ithird_party/cares/cares -Ithird_party/cares/config_linux -Ithird_party/re2 -Ithird_party/boringssl-with-bazel/src/include -Ithird_party/upb -Isrc/core/ext/upb-generated -Isrc/core/ext/upbdefs-generated -Ithird_party/xxhash -Ithird_party/zlib -I/usr/include/python3.9 -c third_party/cares/cares/src/lib/ares_process.c -o python_build/temp.linux-aarch64-cpython-39/third_party/cares/cares/src/lib/ares_process.o -std=c++11 -std=gnu99 -fvisibility=hidden -fno-wrapv -fno-exceptions -pthread
      cc1: warning: command-line option '-std=c++11' is valid for C++/ObjC++ but not for C
      creating None/tmp/tmp_x4urxfk
      gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -g -fno-semantic-interposition -g -fno-semantic-interposition -g -fno-semantic-interposition -DTHREAD_STACK_SIZE=0x100000 -fPIC -I/usr/include/python3.9 -c /tmp/tmp_x4urxfk/a.c -o None/tmp/tmp_x4urxfk/a.o
      Traceback (most recent call last):
        File "/usr/lib/python3.9/site-packages/setuptools/_distutils/unixccompiler.py", line 173, in _compile
          self.spawn(compiler_so + cc_args + [src, '-o', obj] +
        File "/tmp/pip-install-dddnrveo/grpcio_87c868971a7943939c5252f5c860ad57/src/python/grpcio/_spawn_patch.py", line 54, in _commandfile_spawn
          _classic_spawn(self, command)
        File "/usr/lib/python3.9/site-packages/setuptools/_distutils/ccompiler.py", line 917, in spawn
          spawn(cmd, dry_run=self.dry_run, **kwargs)
        File "/usr/lib/python3.9/site-packages/setuptools/_distutils/spawn.py", line 68, in spawn
          raise DistutilsExecError(
      distutils.errors.DistutilsExecError: command '/usr/bin/gcc' failed with exit code 1
      
      During handling of the above exception, another exception occurred:
      
      Traceback (most recent call last):
        File "/tmp/pip-install-dddnrveo/grpcio_87c868971a7943939c5252f5c860ad57/src/python/grpcio/commands.py", line 280, in build_extensions
          build_ext.build_ext.build_extensions(self)
        File "/usr/lib/python3.9/site-packages/setuptools/_distutils/command/build_ext.py", line 448, in build_extensions
          self._build_extensions_serial()
        File "/usr/lib/python3.9/site-packages/setuptools/_distutils/command/build_ext.py", line 473, in _build_extensions_serial
          self.build_extension(ext)
        File "/usr/lib/python3.9/site-packages/setuptools/command/build_ext.py", line 202, in build_extension
          _build_ext.build_extension(self, ext)
        File "/usr/lib/python3.9/site-packages/setuptools/_distutils/command/build_ext.py", line 528, in build_extension
          objects = self.compiler.compile(sources,
        File "/tmp/pip-install-dddnrveo/grpcio_87c868971a7943939c5252f5c860ad57/src/python/grpcio/_parallel_compile_patch.py", line 58, in _parallel_compile
          multiprocessing.pool.ThreadPool(BUILD_EXT_COMPILER_JOBS).map(
        File "/usr/lib/python3.9/multiprocessing/pool.py", line 364, in map
          return self._map_async(func, iterable, mapstar, chunksize).get()
        File "/usr/lib/python3.9/multiprocessing/pool.py", line 771, in get
          raise self._value
        File "/usr/lib/python3.9/multiprocessing/pool.py", line 125, in worker
          result = (True, func(*args, **kwds))
        File "/usr/lib/python3.9/multiprocessing/pool.py", line 48, in mapstar
          return list(map(*args))
        File "/tmp/pip-install-dddnrveo/grpcio_87c868971a7943939c5252f5c860ad57/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 "/usr/lib/python3.9/site-packages/setuptools/_distutils/unixccompiler.py", line 176, in _compile
          raise CompileError(msg)
      distutils.errors.CompileError: command '/usr/bin/gcc' failed with exit code 1
      
      During handling of the above exception, another exception occurred:
      
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "/tmp/pip-install-dddnrveo/grpcio_87c868971a7943939c5252f5c860ad57/setup.py", line 527, in <module>
          setuptools.setup(
        File "/usr/lib/python3.9/site-packages/setuptools/__init__.py", line 87, in setup
          return distutils.core.setup(**attrs)
        File "/usr/lib/python3.9/site-packages/setuptools/_distutils/core.py", line 148, in setup
          return run_commands(dist)
        File "/usr/lib/python3.9/site-packages/setuptools/_distutils/core.py", line 163, in run_commands
          dist.run_commands()
        File "/usr/lib/python3.9/site-packages/setuptools/_distutils/dist.py", line 967, in run_commands
          self.run_command(cmd)
        File "/usr/lib/python3.9/site-packages/setuptools/dist.py", line 1229, in run_command
          super().run_command(command)
        File "/usr/lib/python3.9/site-packages/setuptools/_distutils/dist.py", line 986, in run_command
          cmd_obj.run()
        File "/usr/lib/python3.9/site-packages/setuptools/command/install.py", line 68, in run
          return orig.install.run(self)
        File "/usr/lib/python3.9/site-packages/setuptools/_distutils/command/install.py", line 670, in run
          self.run_command('build')
        File "/usr/lib/python3.9/site-packages/setuptools/_distutils/cmd.py", line 313, in run_command
          self.distribution.run_command(command)
        File "/usr/lib/python3.9/site-packages/setuptools/dist.py", line 1229, in run_command
          super().run_command(command)
        File "/usr/lib/python3.9/site-packages/setuptools/_distutils/dist.py", line 986, in run_command
          cmd_obj.run()
        File "/usr/lib/python3.9/site-packages/setuptools/_distutils/command/build.py", line 136, in run
          self.run_command(cmd_name)
        File "/usr/lib/python3.9/site-packages/setuptools/_distutils/cmd.py", line 313, in run_command
          self.distribution.run_command(command)
        File "/usr/lib/python3.9/site-packages/setuptools/dist.py", line 1229, in run_command
          super().run_command(command)
        File "/usr/lib/python3.9/site-packages/setuptools/_distutils/dist.py", line 986, in run_command
          cmd_obj.run()
        File "/usr/lib/python3.9/site-packages/setuptools/command/build_ext.py", line 79, in run
          _build_ext.run(self)
        File "/usr/lib/python3.9/site-packages/setuptools/_distutils/command/build_ext.py", line 339, in run
          self.build_extensions()
        File "/tmp/pip-install-dddnrveo/grpcio_87c868971a7943939c5252f5c860ad57/src/python/grpcio/commands.py", line 284, in build_extensions
          raise CommandError(
      commands.CommandError: Failed `build_ext` step:
      Traceback (most recent call last):
        File "/usr/lib/python3.9/site-packages/setuptools/_distutils/unixccompiler.py", line 173, in _compile
          self.spawn(compiler_so + cc_args + [src, '-o', obj] +
        File "/tmp/pip-install-dddnrveo/grpcio_87c868971a7943939c5252f5c860ad57/src/python/grpcio/_spawn_patch.py", line 54, in _commandfile_spawn
          _classic_spawn(self, command)
        File "/usr/lib/python3.9/site-packages/setuptools/_distutils/ccompiler.py", line 917, in spawn
          spawn(cmd, dry_run=self.dry_run, **kwargs)
        File "/usr/lib/python3.9/site-packages/setuptools/_distutils/spawn.py", line 68, in spawn
          raise DistutilsExecError(
      distutils.errors.DistutilsExecError: command '/usr/bin/gcc' failed with exit code 1
      
      During handling of the above exception, another exception occurred:
      
      Traceback (most recent call last):
        File "/tmp/pip-install-dddnrveo/grpcio_87c868971a7943939c5252f5c860ad57/src/python/grpcio/commands.py", line 280, in build_extensions
          build_ext.build_ext.build_extensions(self)
        File "/usr/lib/python3.9/site-packages/setuptools/_distutils/command/build_ext.py", line 448, in build_extensions
          self._build_extensions_serial()
        File "/usr/lib/python3.9/site-packages/setuptools/_distutils/command/build_ext.py", line 473, in _build_extensions_serial
          self.build_extension(ext)
        File "/usr/lib/python3.9/site-packages/setuptools/command/build_ext.py", line 202, in build_extension
          _build_ext.build_extension(self, ext)
        File "/usr/lib/python3.9/site-packages/setuptools/_distutils/command/build_ext.py", line 528, in build_extension
          objects = self.compiler.compile(sources,
        File "/tmp/pip-install-dddnrveo/grpcio_87c868971a7943939c5252f5c860ad57/src/python/grpcio/_parallel_compile_patch.py", line 58, in _parallel_compile
          multiprocessing.pool.ThreadPool(BUILD_EXT_COMPILER_JOBS).map(
        File "/usr/lib/python3.9/multiprocessing/pool.py", line 364, in map
          return self._map_async(func, iterable, mapstar, chunksize).get()
        File "/usr/lib/python3.9/multiprocessing/pool.py", line 771, in get
          raise self._value
        File "/usr/lib/python3.9/multiprocessing/pool.py", line 125, in worker
          result = (True, func(*args, **kwds))
        File "/usr/lib/python3.9/multiprocessing/pool.py", line 48, in mapstar
          return list(map(*args))
        File "/tmp/pip-install-dddnrveo/grpcio_87c868971a7943939c5252f5c860ad57/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 "/usr/lib/python3.9/site-packages/setuptools/_distutils/unixccompiler.py", line 176, in _compile
          raise CompileError(msg)
      distutils.errors.CompileError: command '/usr/bin/gcc' failed with exit code 1
      
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure

× Encountered error while trying to install package.
╰─> grpcio

note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-05-22 15:17:53

默认情况下,Alpine的构建环境没有安装。

您需要安装头文件- apk add linux-headers

这是在这个github问题上发现的:不能在高山上安装grpcio

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/72335807

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档