运行
!pip install git+https://github.com/tensorflow/examples.git
报错
Looking in indexes: https://pypi.org/simple, https://us-python.pkg.dev/colab-wheels/public/simple/
Collecting git+https://github.com/tensorflow/examples.git
Cloning https://github.com/tensorflow/examples.git to /tmp/pip-req-build-u7_jdkn8
Running command git clone --filter=blob:none --quiet https://github.com/tensorflow/examples.git /tmp/pip-req-build-u7_jdkn8
Resolved https://github.com/tensorflow/examples.git to commit e3849ccb6d981aad311f0174281c8575d5e21646
error: subprocess-exited-with-error
× python setup.py egg_info did not run successfully.
│ exit code: 1
╰─> See above for output.
note: This error originates from a subprocess, and is likely not a problem with pip.
Preparing metadata (setup.py) ... error
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.

解决方案
# 参考 https://github.com/tensorflow/tensorflow/issues/60106#issuecomment-1487638835
!apt remove git -y # remove any degraded git module
!apt-get install git -y && git clone https://github.com/tensorflow/examples.git # Install git first, then clone.
# 参考 https://github.com/tensorflow/tensorflow/issues/60106#issuecomment-1511149579
import sys
sys.path.append('/content/examples')
import tensorflow_examples
扩展
- tensorflow/examples: TensorFlow examples: https://github.com/tensorflow/examples
同步
- StackOverflow: How to install tensorflow examples in colab
- Q: https://stackoverflow.com/q/76083008/15599248
- A: https://stackoverflow.com/a/76083019/15599248