关于pip安装tensorflow-datasets出现错误的解决方案

问题现象

  1. python编译出现ImportError: No module named ‘tensorflow_datasets’
  2. 使用pip install tensorflow_datasets命令出现如下警告:
    AttributeError: ‘_NamespacePath’ object has no attribute ‘sort’
ERROR: Command errored out with exit status 1:
......
 AttributeError: '_NamespacePath' object has no attribute 'sort'
   --------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

如图:
关于pip安装tensorflow-datasets出现错误的解决方案_第1张图片

解决方法

更新setuptools:

pip3 install --upgrade pip setuptools

继而:

pip3 install tensorflow_datasets

出现如下情况:

ERROR: tensorflow-metadata 0.14.0 has requirement protobuf<4,>=3.7, but you'll have protobuf 3.6.1 which is incompatible.

在这里插入图片描述
运行程序出现错误:

ImportError: This version of TensorFlow Datasets requires TensorFlow version >= 1.13.0; Detected an installation of version 1.12.0. Please upgrade TensorFlow to proceed.

这两个错误显示我该更新tensorflow了。。。
所以:

pip3 install --upgrade tensorflow

然后遇到问题
ImportError: No module named ‘numpy.core._multiarray_umath’
ImportError: numpy.core.multiarray failed to import
于是升级Numpy:

pip3 install --upgrade numpy

于是又遇到问题:
FutureWarning: Passing (type, 1) or ‘1type’ as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / ‘(1,)type’.
关于pip安装tensorflow-datasets出现错误的解决方案_第2张图片
于是将Numpy降到1.17以下
于是

pip3 uninstall numpy
pip3 install "numpy<1.17"

引用与感谢

https://blog.csdn.net/lj19940110/article/details/90105702
https://blog.csdn.net/Dickson531/article/details/78043627
https://segmentfault.com/n/1330000019916555

你可能感兴趣的:(总结与感悟)