grpcio-1.41.1的安装以及排错记录(wheel的一大用处)

人工智能162

grpcio-1.41.1这个版本是比较难以安装的,如果你的操作系统是centos7的话,为什么这么说呢?因为它的安装报错是和gcc环境有关的。

首先,我的服务器是linux7版本,Python2.7环境,gcc版本是默认的4.8.5版本。grpcio的版本可查询到的最新版本就是1.41.1,如下图:

查询需要安装的版本可用版本有哪些,使用命令 pip install 软件包mingc==

root@centos1 ~]# pip install grpcio==
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support pip 21.0 will remove support for this functionality.

Looking in indexes: http://mirrors.aliyun.com/pypi/simple/
ERROR: Could not find a version that satisfies the requirement grpcio== (from versions: 0.4.0a0, 0.4.0a1, 0.4.0a2, 0.4.0a3, 0.4.0a4, 0.4.0a5, 0.4.0a6, 0.4.0a7, 0.4.0a8, 0.4.0a13, 0.4.0a14, 0.5.0a0, 0.5.0a1, 0.5.0a2, 0.9.0a0, 0.9.0a1, 0.10.0a0, 0.11.0b0, 0.11.0b1, 0.12.0b0, 0.13.0, 0.13.1rc1, 0.13.1, 0.14.0rc1, 0.14.0, 0.15.0, 1.0.0rc1, 1.0.0rc2, 1.0.0, 1.0.1rc1, 1.0.1, 1.0.2, 1.0.3, 1.0.4, 1.1.0, 1.1.3, 1.2.0, 1.2.1, 1.3.0, 1.3.3, 1.3.5, 1.4.0, 1.6.0, 1.6.3, 1.7.0, 1.7.3, 1.8.1, 1.8.2, 1.8.3, 1.8.4, 1.8.6, 1.9.0rc1, 1.9.0rc2, 1.9.0rc3, 1.9.0, 1.9.1, 1.10.0rc2, 1.10.0, 1.10.1rc1, 1.10.1rc2, 1.10.1, 1.11.0rc1, 1.11.0rc2, 1.11.0, 1.11.1rc1, 1.11.1, 1.12.0rc1, 1.12.0, 1.12.1, 1.13.0rc1, 1.13.0rc2, 1.13.0rc3, 1.13.0, 1.14.0rc1, 1.14.0rc2, 1.14.0, 1.14.1, 1.14.2rc1, 1.14.2, 1.15.0rc1, 1.15.0, 1.16.0rc1, 1.16.0, 1.16.1, 1.17.0, 1.17.1, 1.18.0, 1.19.0, 1.20.0rc1, 1.20.0rc2, 1.20.0rc3, 1.20.0, 1.20.1, 1.21.0rc1, 1.21.1rc1, 1.21.1, 1.22.0rc1, 1.22.0, 1.22.1, 1.23.0rc1, 1.23.0, 1.23.1, 1.24.0rc1, 1.24.0, 1.24.1, 1.24.3, 1.25.0rc1, 1.25.0, 1.26.0rc1, 1.26.0, 1.27.0rc1, 1.27.0rc2, 1.27.1, 1.27.2, 1.28.0rc1, 1.28.0rc2, 1.28.1, 1.29.0, 1.30.0, 1.31.0, 1.32.0, 1.33.1, 1.33.2, 1.34.0rc1, 1.34.0, 1.34.1, 1.35.0rc1, 1.35.0, 1.36.0rc1, 1.36.0, 1.36.1, 1.37.0rc1, 1.37.0, 1.37.1, 1.38.0rc1, 1.38.0, 1.38.1, 1.39.0rc1, 1.39.0, 1.40.0rc1, 1.40.0, 1.41.0rc2, 1.41.0, 1.41.1)
ERROR: No matching distribution found for grpcio==

这里可以看到最高版本是1.41.1,但需要注意的是,这里表示的是Python2.7最高的可支持的grpcio的版本是1.41.1 ,如果是Python3比如3.8,那么,可支持的版本就更高了。3.8查询出的示例如下:

[root@slave2 ~]# pip install grpcio==
Looking in indexes: http://mirrors.aliyun.com/pypi/simple/
ERROR: Could not find a version that satisfies the requirement grpcio== (from versions: 0.4.0a0, 0.4.0a1, 0.4.0a2, 0.4.0a3, 0.4.0a4, 0.4.0a5, 0.4.0a6, 0.4.0a7, 0.4.0a8, 0.4.0a13, 0.4.0a14, 0.5.0a0, 0.5.0a1, 0.5.0a2, 0.9.0a0, 0.9.0a1, 0.10.0a0, 0.11.0b0, 0.11.0b1, 0.12.0b0, 0.13.0, 0.13.1rc1, 0.13.1, 0.14.0rc1, 0.14.0, 0.15.0, 1.0.0rc1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c1, 1.46.0rc2, 1.46.0, 1.46.1, 1.46.3)
ERROR: No matching distribution found for grpcio==

直接安装这个1.41.1可以吗?答案是否定的,必须先把gcc的版本升高到至少6才可以哦。

在gcc4.8下其中的一段报错如下:

 -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/python2.7 -c src/core/ext/upb-generated/udpa/annotations/migrate.upb.c -o python_build/temp.linux-x86_64-2.7/src/core/ext/upb-generated/udpa/annotations/migrate.upb.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 [enabled by default]
  cc1: warning: command line option '-std=c++11' is valid for C++/ObjC++ but not for C [enabled by default]
  src/python/grpcio/grpc/_cython/cygrpc.cpp: In function 'PyObject* __pyx_pw_4grpc_7_cython_6cygrpc_7Channel_9segregated_call(PyObject*, PyObject*, PyObject*)':
  src/python/grpcio/grpc/_cython/cygrpc.cpp:18702:76: warning: '__pyx_v_c_completion_queue' may be used uninitialized in this function [-Wmaybe-uninitialized]

其中,cc1: warning: command line option '-std=c++11' is valid for C++/ObjC++ but not for C [enabled by default]是提示gcc版本不够。

还有一段报错如下:

Cython-generated files are missing...
We could not find Cython. Setup may take 10-20 minutes.

这个就是单纯的提示没有安装Cython程序将会跑10到20分钟。

解决方案:

安装Cython,临时提升gcc版本到6即可。

执行命令:pip install Cython

root@centos1 ~]# tar xf gcc-6.tar
[root@centos1 ~]# mkdir /opt/rh
[root@centos1 ~]# mv devtoolset-6 /opt/rh/
[root@centos1 ~]# source /opt/rh/devtoolset-6/enable
[root@centos1 ~]#
[root@centos1 ~]# pip install grpcio==1.41.1
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support pip 21.0 will remove support for this functionality.
Looking in indexes: http://mirrors.aliyun.com/pypi/simple/
Collecting grpcio==1.41.1
Downloading http://mirrors.aliyun.com/pypi/packages/bd/81/6c704c002a992b9d6466c739e3e7687e0bb2365d8cd63d7fc8e95d502cb6/grpcio-1.41.1.tar.gz (21.2 MB)
|████████████████████████████████| 21.2 MB 11.6 MB/s
Requirement already satisfied: six>=1.5.2 in /usr/lib/python2.7/site-packages (from grpcio==1.41.1) (1.16.0)
Requirement already satisfied: enum34>=1.0.4 in /usr/lib/python2.7/site-packages (from grpcio==1.41.1) (1.1.10)
Requirement already satisfied: futures>=2.2.0 in /usr/lib/python2.7/site-packages (from grpcio==1.41.1) (3.3.0)
Building wheels for collected packages: grpcio
Building wheel for grpcio (setup.py) ... done
Created wheel for grpcio: filename=grpcio-1.41.1-cp27-cp27mu-linux_x86_64.whl size=38482692 sha256=f739d6dc50b9d9566757accdbaa2c2dfe3bceeabc7134c6767e3b2f9d870a452
Stored in directory: /root/.cache/pip/wheels/c7/ed/27/f189d34b2e7c42eb5e9ffd14fbe2cad21efe7502a5d7516d27
Successfully built grpcio
Installing collected packages: grpcio
Attempting uninstall: grpcio
Found existing installation: grpcio 1.37.1
Uninstalling grpcio-1.37.1:
Successfully uninstalled grpcio-1.37.1
Successfully installed grpcio-1.41.1

上面我使用了wheel自动构造轮子,轮子文件生成在了这个提示的地方:

Stored in directory: /root/.cache/pip/wheels/c7/ed/27/f189d34b2e7c42eb5e9ffd14fbe2cad21efe7502a5d7516d27

我的轮子的版本:

[root@centos1 ~]# pip list |grep wheel
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support pip 21.0 will remove support for this functionality.

wheel                0.36.2

那么,这个新生成的文件有什么用处呢?其实既然叫轮子,那么,表达的意思就是这个文件可以在其它的任意的centos7系列操作系统下使用,直接pip install 轮子文件就可以安装好了,不需要高版本的gcc啦(依赖还是需要的 ,依赖是三个Requirement already satisfied: six>=1.5.2 in /usr/lib/python2.7/site-packages (from grpcio==1.41.1) (1.16.0)
Requirement already satisfied: enum34>=1.0.4 in /usr/lib/python2.7/site-packages (from grpcio==1.41.1) (1.1.10)
Requirement already satisfied: futures>=2.2.0 in /usr/lib/python2.7/site-packages (from grpcio==1.41.1) (3.3.0))。

如果没有安装wheel,那么,将不会生成wheel文件,也就是不会有如下提示,此时的安装应该是这样的:

[root@centos1 ~]# pip install grpcio==1.40
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support pip 21.0 will remove support for this functionality.

Looking in indexes: http://mirrors.aliyun.com/pypi/simple/
Collecting grpcio==1.40
  Downloading http://mirrors.aliyun.com/pypi/packages/37/56/700ff83b59eb69a7ddd62840666699173923020cfdf33a2860b9eba5667a/grpcio-1.40.0.tar.gz (21.3 MB)
     |████████████████████████████████| 21.3 MB 12.3 MB/s
Requirement already satisfied: six>=1.5.2 in /usr/lib/python2.7/site-packages (from grpcio==1.40) (1.16.0)
Requirement already satisfied: enum34>=1.0.4 in /usr/lib/python2.7/site-packages (from grpcio==1.40) (1.1.10)
Requirement already satisfied: futures>=2.2.0 in /usr/lib/python2.7/site-packages (from grpcio==1.40) (3.3.0)
Using legacy 'setup.py install' for grpcio, since package 'wheel' is not installed.

Installing collected packages: grpcio
  Attempting uninstall: grpcio
    Found existing installation: grpcio 1.41.1
    Uninstalling grpcio-1.41.1:
      Successfully uninstalled grpcio-1.41.1
    Running setup.py install for grpcio ...

也就是Using legacy 'setup.py install' for grpcio, since package 'wheel' is not installed,然后直接安装了,那么,你如果需要移植这个库,在别的服务器上将需要重新激活gcc6,然后重复安装步骤啦,如果有轮子,只需要将轮子文件grpcio-1.41.1-cp27-cp27mu-linux_x86_64.whl 拷贝到其它服务器上,安装它就可以了,可以省很多的时间和精力,非常的方便快捷。

Original: https://blog.csdn.net/alwaysbefine/article/details/124917333
Author: zsk_john
Title: grpcio-1.41.1的安装以及排错记录(wheel的一大用处)

相关文章
Vue之axios基础使用 人工智能

Vue之axios基础使用

axios 简介 axios 是一个基于Promise 用于浏览器和 nodejs 的 HTTP 客户端,它本身具有以下特征: 从浏览器中创建 XMLHttpRequest 从 node.js 发出 ...
人体姿态估计 Android端 ncnn 人工智能

人体姿态估计 Android端 ncnn

去年由于一些原因,需要在手机端部署人体姿态估计模型,早就写完了,但由于一些原因一直没有记录下来。大致的过程是,经过一番百度,找到了一个名为ncnn的框架,然后参考ncnn-android-yolox的...
deepspeech 笔记 人工智能

deepspeech 笔记

为了回馈广大粉丝和订阅者,在以前的笔记中看到些或许对大家有用的信息,贴到这里,希望能对大家有帮助。 文章目录 * - + 几个模块 + 几份数据 + 几篇论文 + 几张截图 几个模块 声学模型主要用来...