为什么我的系统上没有安装 `grpc` 软件包?

问题描述 投票:0回答:1

嗨,我正在尝试通过 pip 安装

grpc
python 包。它实际上是打算通过我正在做的另一个设置的构建脚本来安装的,但脚本一直失败,所以我决定自己做。

这是我得到的:

❯ pip3 install grpc
Defaulting to user installation because normal site-packages is not writeable
Collecting grpc
  Using cached grpc-1.0.0.tar.gz (5.2 kB)
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error
  
  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [6 lines of output]
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "/tmp/pip-install-_au3535m/grpc_0b2b1ce7560943288874cf94aa72394a/setup.py", line 33, in <module>
          raise RuntimeError(HINT)
      RuntimeError: Please install the official package with: pip install grpcio
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

我已尝试按照提示操作:

pip install grpcio

并且运行没有任何问题。我还通过搜索关键词访问了大量的论坛:“setup.py Egg_info 没有成功运行”,所有建议的做法是:

pip install --upgrade pip
pip install --upgrade setuptools

我都尝试了,这就是我得到的:

Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: pip in /home/utl/.local/lib/python3.10/site-packages (24.0)
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: setuptools in /usr/local/lib/python3.10/dist-packages (69.5.1)

然而,当我之后运行

pip install grpc
时,它不起作用,并且出现与以前相同的错误。我已经在构建脚本上苦苦挣扎了一段时间,所以非常感谢您的帮助。

python pip
1个回答
1
投票

您不能(也不应该尝试)安装

grpc
PyPI 包,因为它只是一个告诉您安装
grpcio
的存根。

grpcio
PyPI 包提供了
grpc
Python包:

# pip install grpcio
Collecting grpcio
Successfully installed grpcio-1.63.0
# python
Python 3.12.1 (main, Jan 17 2024, 06:18:08) [GCC 12.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import grpc
>>> grpc
<module 'grpc' from '/usr/local/lib/python3.12/site-packages/grpc/__init__.py'>
>>>

如果您有一个正在尝试安装的构建脚本

grpc
,则该脚本已损坏和/或已过时。

© www.soinside.com 2019 - 2024. All rights reserved.