统信UOS Linux操作系统下安装TensorFlow遇到的tensorflow-io-gcs-filesystem问题

在这里插入图片描述

##一、 安装指令

pip3 install tensorflow -i https://pypi.tuna.tsinghua.edu.cn/simple

执行安装后,成功安装相关依赖库和TensorFlow,最后2行安装程序输出信息如下:

Installing collected packages: tensorflow-io-gcs-filesystem, tensorflow
Successfully installed tensorflow-2.11.0 tensorflow-io-gcs-filesystem-0.29.0

二、测试

1、运行Python3

(aiStudy) administrator@jwp:~/Desktop/aiStudy$ python3
Python 3.7.3 (default, Oct 13 2023, 10:47:37) 
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 

2、执行import

>>> import tensorflow as tf
/home/administrator/Desktop/aiStudy/lib/python3.7/site-packages/tensorflow_io/python/ops/__init__.py:98: UserWarning: unable to load libtensorflow_io_plugins.so: unable to open file: libtensorflow_io_plugins.so, from paths: ['/home/administrator/Desktop/aiStudy/lib/python3.7/site-packages/tensorflow_io/python/ops/libtensorflow_io_plugins.so']
caused by: ["[Errno 2] The file to load file system plugin from does not exist.: '/home/administrator/Desktop/aiStudy/lib/python3.7/site-packages/tensorflow_io/python/ops/libtensorflow_io_plugins.so'"]
  warnings.warn(f"unable to load libtensorflow_io_plugins.so: {e}")
/home/administrator/Desktop/aiStudy/lib/python3.7/site-packages/tensorflow_io/python/ops/__init__.py:104: UserWarning: file system plugins are not loaded: unable to open file: libtensorflow_io.so, from paths: ['/home/administrator/Desktop/aiStudy/lib/python3.7/site-packages/tensorflow_io/python/ops/libtensorflow_io.so']
caused by: ['/home/administrator/Desktop/aiStudy/lib/python3.7/site-packages/tensorflow_io/python/ops/libtensorflow_io.so: cannot open shared object file: No such file or directory']
  warnings.warn(f"file system plugins are not loaded: {e}")

可以看到有警告信息,是加载tensorflow_io失败,TensorFlow I/O 是一个扩展库,为 TensorFlow 提供了对各种文件系统和数据格式的支持。它不是 TensorFlow 的核心组件,但是提供了一些额外的功能,比如:

  • 支持多种文件系统:包括本地文件系统、HDFS、GCS(Google Cloud Storage)、S3(Amazon Simple Storage Service)等
  • 支持多种数据格式:如 Apache Parquet、Apache Avro 等
  • 数据管道功能:提供高级的数据输入管道操作,以简化数据加载和预处理的代码。

而这个库安装TensorFlow时并没有手动安装,也没有作为依赖项自动安装,因此怀疑是自动安装依赖库tensorflow-io-gcs-filesystem导致的。

3、检查TensorFlow依赖关系

检查依赖关系需要使用pipdeptree,pipdeptree 是一个命令行工具,用于显示 Python 环境中安装的包及其依赖关系的树状图。可以展示不同包之间的依赖关系,以及哪些包可能间接依赖于其他包。

安装pipdeptree及用之检查TensorFlow的依赖关系的指令及执行情况如下:

(aiStudy) administrator@jwp:~/Desktop/aiStudy$ pip3 install pipdeptree
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting pipdeptree
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/41/2c/63ad89d8e01d471b91c0ad4d69ed45f5221f70f3ece6c097beecb7c67f7a/pipdeptree-2.9.6-py3-none-any.whl (19 kB)
Installing collected packages: pipdeptree
Successfully installed pipdeptree-2.9.6

(aiStudy) administrator@jwp:~/Desktop/aiStudy$ pipdeptree | grep tensorflow
tensorflow==2.11.0
  - tensorflow-cpu-aws [required: ==2.11.0, installed: 2.11.0]
    - tensorflow-estimator [required: >=2.11.0,<2.12, installed: 2.11.0]
    - tensorflow-io-gcs-filesystem [required: >=0.23.1, installed: 0.29.0]

可以看到tensorflow依赖tensorflow-cpu-aws,而tensorflow-cpu-aws依赖tensorflow-estimator和tensorflow-io-gcs-filesystem。

卸载tensorflow-io-gcs-filesystem试试:

(aiStudy) administrator@jwp:~/Desktop/aiStudy$ pip3 uninstall tensorflow-io-gcs-filesystem
Found existing installation: tensorflow-io-gcs-filesystem 0.29.0
Uninstalling tensorflow-io-gcs-filesystem-0.29.0:
  Would remove:
    /home/administrator/Desktop/aiStudy/lib/python3.7/site-packages/tensorflow_io/*
    /home/administrator/Desktop/aiStudy/lib/python3.7/site-packages/tensorflow_io_gcs_filesystem-0.29.0.dist-info/*
    /home/administrator/Desktop/aiStudy/lib/python3.7/site-packages/tensorflow_io_gcs_filesystem/*
Proceed (Y/n)? y
  Successfully uninstalled tensorflow-io-gcs-filesystem-0.29.0

卸载成功后重新检测依赖关系:

(aiStudy) administrator@jwp:~/Desktop/aiStudy$ pipdeptree | grep tensorflowWarning!!! Possibly conflicting dependencies found:
* tensorflow-cpu-aws==2.11.0
 - tensorflow-io-gcs-filesystem [required: >=0.23.1, installed: ?]
------------------------------------------------------------------------
tensorflow==2.11.0
  - tensorflow-cpu-aws [required: ==2.11.0, installed: 2.11.0]
    - tensorflow-estimator [required: >=2.11.0,<2.12, installed: 2.11.0]
    - tensorflow-io-gcs-filesystem [required: >=0.23.1, installed: ?]

可以看到tensorflow-io-gcs-filesystem 的安装状态为问号,没有安装,但依赖tensorflow-io-gcs-filesystem 的上层库并没受影响,是否影响程序运行暂时未知。

我们重新执行import tensorflow:

(aiStudy) administrator@jiangwenping:~/Desktop/aiStudy$ python3
Python 3.7.3 (default, Oct 13 2023, 10:47:37) 
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
>>> 

可以看到正常执行,无警告信息。

四、小结

由于笔者统信UOS机器没有使用tensorflow-io-gcs-filesystem运行环境,但安装TensorFlow却自动安装了tensorflow-io-gcs-filesystem,导致import tensorflow时加载tensorflow_io失败报错,解决办法就是执行pip3 uninstall tensorflow-io-gcs-filesystem卸载tensorflow-io-gcs-filesystem即可。

更多人工智能知识学习请关注专栏《零基础机器学习入门》后续的文章。

更多人工智能知识学习过程中可能遇到的疑难问题及解决办法请关注专栏《机器学习疑难问题集》后续的文章。

写博不易,敬请支持:

如果阅读本文于您有所获,敬请点赞、评论、收藏,谢谢大家的支持!

关于老猿的付费专栏

  1. 付费专栏《https://blog.csdn.net/laoyuanpython/category_9607725.html 使用PyQt开发图形界面Python应用》专门介绍基于Python的PyQt图形界面开发基础教程,对应文章目录为《 https://blog.csdn.net/LaoYuanPython/article/details/107580932 使用PyQt开发图形界面Python应用专栏目录》;
  2. 付费专栏《https://blog.csdn.net/laoyuanpython/category_10232926.html moviepy音视频开发专栏 )详细介绍moviepy音视频剪辑合成处理的类相关方法及使用相关方法进行相关剪辑合成场景的处理,对应文章目录为《https://blog.csdn.net/LaoYuanPython/article/details/107574583 moviepy音视频开发专栏文章目录》;
  3. 付费专栏《https://blog.csdn.net/laoyuanpython/category_10581071.html OpenCV-Python初学者疑难问题集》为《https://blog.csdn.net/laoyuanpython/category_9979286.html OpenCV-Python图形图像处理 》的伴生专栏,是笔者对OpenCV-Python图形图像处理学习中遇到的一些问题个人感悟的整合,相关资料基本上都是老猿反复研究的成果,有助于OpenCV-Python初学者比较深入地理解OpenCV,对应文章目录为《https://blog.csdn.net/LaoYuanPython/article/details/109713407 OpenCV-Python初学者疑难问题集专栏目录
  4. 付费专栏《https://blog.csdn.net/laoyuanpython/category_10762553.html Python爬虫入门 》站在一个互联网前端开发小白的角度介绍爬虫开发应知应会内容,包括爬虫入门的基础知识,以及爬取CSDN文章信息、博主信息、给文章点赞、评论等实战内容。

前两个专栏都适合有一定Python基础但无相关知识的小白读者学习,第三个专栏请大家结合《https://blog.csdn.net/laoyuanpython/category_9979286.html OpenCV-Python图形图像处理 》的学习使用。

对于缺乏Python基础的同仁,可以通过老猿的免费专栏《https://blog.csdn.net/laoyuanpython/category_9831699.html 专栏:Python基础教程目录)从零开始学习Python。

如果有兴趣也愿意支持老猿的读者,欢迎购买付费专栏。

老猿Python,跟老猿学Python!

☞ ░ 前往老猿Python博文目录 https://blog.csdn.net/LaoYuanPython
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

LaoYuanPython

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值