Windows系统Python3.9虚拟环境中tensorflow-io安装失败求助
我正在跟着视频教程学习RNN,尝试运行一个RNN示例笔记本时,用命令 pip install tensorflow-io 安装tensorflow-io,结果遇到了报错:
ERROR: Could not find a version that satisfies the requirement tensorflow-io (from versions: none)
ERROR: No matching distribution found for tensorflow-io
我换了新的虚拟环境(创建时特意指定了Python3.9版本),成功安装了TensorFlow,但再次尝试安装tensorflow-io时还是出现同样的错误。另外这个操作在Mac和Colab上都能正常完成,只有Windows系统的Python3.9虚拟环境里出问题,有没有人能帮我解决这个问题?
我之前也遇到过类似的环境适配问题,给你几个针对性的解决方案,你可以逐个尝试:
严格匹配TensorFlow与tensorflow-io的版本
tensorflow-io和TensorFlow的版本是强绑定的,版本不对应就会找不到匹配的安装包。先运行pip show tensorflow查看你当前安装的TensorFlow版本,然后按照对应关系指定tensorflow-io的版本安装:- TensorFlow 2.9.x → tensorflow-io 0.26.x
- TensorFlow 2.10.x → tensorflow-io 0.27.x
- TensorFlow 2.11.x → tensorflow-io 0.28.x
举个例子,如果你的TensorFlow是2.10.0,就执行命令:pip install tensorflow-io==0.27.0
切换国内pip源尝试安装
有时候是网络或PyPI源的问题导致包检索失败,你可以换成国内的镜像源试试:pip install tensorflow-io -i https://pypi.tuna.tsinghua.edu.cn/simple尝试用conda安装(如果有conda环境)
如果pip安装始终失败,conda的conda-forge频道通常有更多适配Windows的预编译包,你可以尝试:conda install -c conda-forge tensorflow-io从源码编译安装(备选方案)
如果实在找不到适配Windows Python3.9的预编译包,只能尝试从源码编译:- 克隆tensorflow-io的官方代码仓库
- 切换到与你当前TensorFlow版本对应的分支(比如TensorFlow 2.10对应r0.27分支)
- 进入仓库目录,执行
pip install -e .完成编译安装
备注:内容来源于stack exchange,提问作者Sai venkata Sandeep

