Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-q9rtk_fz/grpcio/ の対処法

# やりたいこと

CentOS7+Python3.6.8の環境にて
pip3でtensorflowを入れてから、kerasを入れたい。


# 現象

```
pip3 install --upgrade tensorflow
```

を実行すると、

```
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-q9rtk_fz/grpcio/
```

が発生する。

# 対策

下記を実行する。

### pip3 install --upgrade pip

```
pip3 install --upgrade pip

WARNING: Running pip install with root privileges is generally not a good idea. Try `pip3 install --user` instead.
Collecting pip
  Downloading https://files.pythonhosted.org/packages/cb/28/91f26bd088ce8e22169032100d4260614fc3da435025ff389ef1d396a433/pip-20.2.4-py2.py3-none-any.whl (1.5MB)
    100% |################################| 1.5MB 1.3MB/s
Installing collected packages: pip
Successfully installed pip-20.2.4
```

その後、

### pip3 install --upgrade tensorflow

```
pip3 install --upgrade tensorflow

WARNING: pip is being invoked by an old script wrapper. This will fail in a future version of pip.
Please see https://github.com/pypa/pip/issues/5599 for advice on fixing the underlying issue.
To avoid this problem you can invoke Python with '-m pip' instead of running pip directly.
Collecting tensorflow
  Downloading tensorflow-2.3.1-cp36-cp36m-manylinux2010_x86_64.whl (320.4 MB)
     |################################| 320.4 MB 33 kB/s
Collecting termcolor>=1.1.0
  Using cached termcolor-1.1.0.tar.gz (3.9 kB)
Collecting absl-py>=0.7.0
  Using cached absl_py-0.11.0-py3-none-any.whl (127 kB)
Collecting google-pasta>=0.1.8
  Using cached google_pasta-0.2.0-py3-none-any.whl (57 kB)
Collecting numpy<1.19.0,>=1.16.0
  Downloading numpy-1.18.5-cp36-cp36m-manylinux1_x86_64.whl (20.1 MB)
     |################################| 20.1 MB 38.1 MB/s
Collecting protobuf>=3.9.2
  Using cached protobuf-3.14.0-cp36-cp36m-manylinux1_x86_64.whl (1.0 MB)
Collecting h5py<2.11.0,>=2.10.0
  Downloading h5py-2.10.0-cp36-cp36m-manylinux1_x86_64.whl (2.9 MB)
     |################################| 2.9 MB 85.8 MB/s
Collecting tensorboard<3,>=2.3.0
  Downloading tensorboard-2.4.0-py3-none-any.whl (10.6 MB)
     |################################| 10.6 MB 59.7 MB/s
Collecting grpcio>=1.8.6
  Downloading grpcio-1.33.2-cp36-cp36m-manylinux2014_x86_64.whl (3.8 MB)
     |################################| 3.8 MB 18.3 MB/s
Collecting gast==0.3.3
  Downloading gast-0.3.3-py2.py3-none-any.whl (9.7 kB)
Collecting wheel>=0.26
  Downloading wheel-0.35.1-py2.py3-none-any.whl (33 kB)
Collecting wrapt>=1.11.1
  Using cached wrapt-1.12.1.tar.gz (27 kB)
Collecting six>=1.12.0
  Using cached six-1.15.0-py2.py3-none-any.whl (10 kB)
Collecting keras-preprocessing<1.2,>=1.1.1
  Using cached Keras_Preprocessing-1.1.2-py2.py3-none-any.whl (42 kB)
Collecting opt-einsum>=2.3.2
  Downloading opt_einsum-3.3.0-py3-none-any.whl (65 kB)
     |################################| 65 kB 6.7 MB/s
Collecting tensorflow-estimator<2.4.0,>=2.3.0
  Downloading tensorflow_estimator-2.3.0-py2.py3-none-any.whl (459 kB)
     |################################| 459 kB 80.6 MB/s
Collecting astunparse==1.6.3
  Downloading astunparse-1.6.3-py2.py3-none-any.whl (12 kB)
Collecting tensorboard-plugin-wit>=1.6.0
  Downloading tensorboard_plugin_wit-1.7.0-py3-none-any.whl (779 kB)
     |################################| 779 kB 70.1 MB/s
Collecting setuptools>=41.0.0
  Downloading setuptools-50.3.2-py3-none-any.whl (785 kB)
     |################################| 785 kB 78.3 MB/s
Collecting google-auth<2,>=1.6.3
  Downloading google_auth-1.23.0-py2.py3-none-any.whl (114 kB)
     |################################| 114 kB 83.9 MB/s
Collecting google-auth-oauthlib<0.5,>=0.4.1
  Downloading google_auth_oauthlib-0.4.2-py2.py3-none-any.whl (18 kB)
Collecting requests<3,>=2.21.0
  Downloading requests-2.25.0-py2.py3-none-any.whl (61 kB)
     |################################| 61 kB 11.7 MB/s
Collecting markdown>=2.6.8
  Downloading Markdown-3.3.3-py3-none-any.whl (96 kB)
     |################################| 96 kB 8.6 MB/s
Collecting werkzeug>=0.11.15
  Downloading Werkzeug-1.0.1-py2.py3-none-any.whl (298 kB)
     |################################| 298 kB 71.2 MB/s
Collecting pyasn1-modules>=0.2.1
  Downloading pyasn1_modules-0.2.8-py2.py3-none-any.whl (155 kB)
     |################################| 155 kB 81.5 MB/s
Collecting cachetools<5.0,>=2.0.0
  Downloading cachetools-4.1.1-py3-none-any.whl (10 kB)
Collecting rsa<5,>=3.1.4; python_version >= "3.5"
  Downloading rsa-4.6-py3-none-any.whl (47 kB)
     |################################| 47 kB 7.9 MB/s
Collecting requests-oauthlib>=0.7.0
  Downloading requests_oauthlib-1.3.0-py2.py3-none-any.whl (23 kB)
Collecting idna<3,>=2.5
  Downloading idna-2.10-py2.py3-none-any.whl (58 kB)
     |################################| 58 kB 9.1 MB/s
Collecting urllib3<1.27,>=1.21.1
  Downloading urllib3-1.26.2-py2.py3-none-any.whl (136 kB)
     |################################| 136 kB 87.1 MB/s
Collecting certifi>=2017.4.17
  Downloading certifi-2020.11.8-py2.py3-none-any.whl (155 kB)
     |################################| 155 kB 26.4 MB/s
Collecting chardet<4,>=3.0.2
  Downloading chardet-3.0.4-py2.py3-none-any.whl (133 kB)
     |################################| 133 kB 69.0 MB/s
Collecting importlib-metadata; python_version < "3.8"
  Downloading importlib_metadata-2.0.0-py2.py3-none-any.whl (31 kB)
Collecting pyasn1<0.5.0,>=0.4.6
  Downloading pyasn1-0.4.8-py2.py3-none-any.whl (77 kB)
     |################################| 77 kB 10.4 MB/s
Collecting oauthlib>=3.0.0
  Downloading oauthlib-3.1.0-py2.py3-none-any.whl (147 kB)
     |################################| 147 kB 83.9 MB/s
Collecting zipp>=0.5
  Downloading zipp-3.4.0-py3-none-any.whl (5.2 kB)
Using legacy 'setup.py install' for termcolor, since package 'wheel' is not installed.
Using legacy 'setup.py install' for wrapt, since package 'wheel' is not installed.
Installing collected packages: termcolor, six, absl-py, google-pasta, numpy, protobuf, h5py, tensorboard-plugin-wit, setuptools, pyasn1, pyasn1-modules, cachetools, rsa, google-auth, wheel, oauthlib, idna, urllib3, certifi, chardet, requests, requests-oauthlib, google-auth-oauthlib, zipp, importlib-metadata, markdown, werkzeug, grpcio, tensorboard, gast, wrapt, keras-preprocessing, opt-einsum, tensorflow-estimator, astunparse, tensorflow
    Running setup.py install for termcolor ... done
  Attempting uninstall: setuptools
    Found existing installation: setuptools 39.2.0
    Uninstalling setuptools-39.2.0:
      Successfully uninstalled setuptools-39.2.0
    Running setup.py install for wrapt ... done
Successfully installed absl-py-0.11.0 astunparse-1.6.3 cachetools-4.1.1 certifi-2020.11.8 chardet-3.0.4 gast-0.3.3 google-auth-1.23.0 google-auth-oauthlib-0.4.2 google-pasta-0.2.0 grpcio-1.33.2 h5py-2.10.0 idna-2.10 importlib-metadata-2.0.0 keras-preprocessing-1.1.2 markdown-3.3.3 numpy-1.18.5 oauthlib-3.1.0 opt-einsum-3.3.0 protobuf-3.14.0 pyasn1-0.4.8 pyasn1-modules-0.2.8 requests-2.25.0 requests-oauthlib-1.3.0 rsa-4.6 setuptools-50.3.2 six-1.15.0 tensorboard-2.4.0 tensorboard-plugin-wit-1.7.0 tensorflow-2.3.1 tensorflow-estimator-2.3.0 termcolor-1.1.0 urllib3-1.26.2 werkzeug-1.0.1 wheel-0.35.1 wrapt-1.12.1 zipp-3.4.0
[root@creator ~]#
```

で成功。

その後、

### pip3 install keras

```
pip3 install keras

WARNING: pip is being invoked by an old script wrapper. This will fail in a future version of pip.
Please see https://github.com/pypa/pip/issues/5599 for advice on fixing the underlying issue.
To avoid this problem you can invoke Python with '-m pip' instead of running pip directly.
Collecting keras
  Downloading Keras-2.4.3-py2.py3-none-any.whl (36 kB)
Collecting scipy>=0.14
  Downloading scipy-1.5.4-cp36-cp36m-manylinux1_x86_64.whl (25.9 MB)
     |################################| 25.9 MB 20.8 MB/s
Requirement already satisfied: numpy>=1.9.1 in /usr/local/lib64/python3.6/site-packages (from keras) (1.18.5)
Requirement already satisfied: h5py in /usr/local/lib64/python3.6/site-packages (from keras) (2.10.0)
Collecting pyyaml
  Downloading PyYAML-5.3.1.tar.gz (269 kB)
     |################################| 269 kB 71.6 MB/s
Requirement already satisfied: six in /usr/local/lib/python3.6/site-packages (from h5py->keras) (1.15.0)
Building wheels for collected packages: pyyaml
  Building wheel for pyyaml (setup.py) ... done
  Created wheel for pyyaml: filename=PyYAML-5.3.1-cp36-cp36m-linux_x86_64.whl size=44619 sha256=249c8446bb49aafbae06d7883b9e4e5331fcc9270ad65b5d2f7d97599566ce98
  Stored in directory: /root/.cache/pip/wheels/e5/9d/ad/2ee53cf262cba1ffd8afe1487eef788ea3f260b7e6232a80fc
Successfully built pyyaml
Installing collected packages: scipy, pyyaml, keras
Successfully installed keras-2.4.3 pyyaml-5.3.1 scipy-1.5.4
```

も成功。