无法在M1上安装tensorflow-io。

10

我无法在M1 Mac环境下安装tensorflow-io。虽然已成功安装了tensorflow-macos和其他库,但在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"

机器:M1 Mac

操作系统:MacOS Monterey 12.0.1

环境:Miniforge

Python版本:3.9

Tensorflow版本:2.5.0

3个回答

7

您可以使用Wheel文件安装TensorFlow IO。

首先,按照以下方式克隆TensorFlow/IO存储库并构建它。

$ python3 setup.py -q bdist_wheel

Wheel文件将被创建在dist目录中。 然后,您可以通过执行以下步骤来安装wheel。

$ python3 -m pip install --no-deps <wheel-file-build-from-last-step>

供您参考,我在我的环境中运行的结果如下。

$ git clone https://github.com/tensorflow/io.git
$ cd io
$ python3 setup.py -q bdist_wheel
Project: tensorflow-io
Exclude: ['tests', 'tests.*', 'tensorflow_io_gcs_filesystem', 
'tensorflow_io_gcs_filesystem.*']
Install Requires: ['tensorflow-io-gcs-filesystem==0.24.0']
Project Rootpath: tensorflow_io
$ python3 -m pip install --no-deps dist/tensorflow_io-0.24.0-cp39-cp39-macosx_11_0_arm64.whl
Processing ./dist/tensorflow_io-0.24.0-cp39-cp39-macosx_11_0_arm64.whl
Installing collected packages: tensorflow-io
Successfully installed tensorflow-io-0.24.0

由于版本经常更新,请记得检查dist/并替换文件名,例如: tensorflow_io-0.27.0-cp310-cp310-macosx_12_0_arm64.whl

参考链接:M1芯片的arm64支持


2
在 M1 air 上,我遇到了以下错误:ERROR: tensorflow_io-0.24.0-cp38-cp38-macosx_10_14_arm64.whl 不支持此平台。 - potatochemist
2
我得到了这个错误:SetuptoolsDeprecationWarning: setup.py install已被弃用。请使用基于标准的工具,如build和pip。 warnings.warn() - Jana.k
2
@Jana.k 我刚刚花了4个小时“调试”同一个问题,直到我意识到:那不是一个失败,只是一个警告。如果你检查dist/文件夹,你可能会发现这个wheel已经成功构建了。 - damian
1
安装完成且无错误,我可以导入。但是当尝试使用 tfio.audio.AudioIOTensor(fname) 加载音频文件时,我遇到了一个 NotImplementedError: unable to open file: libtensorflow_io.so 错误。有人运气更好吗? - Thiago Gouvea

3

克隆 TensorFlow IO GitHub 存储库

git clone https://github.com/tensorflow/io.git
cd io

然后进入dst目录并列出文件

python3 setup.py -q bdist_wheel
python3 setup.py -q bdist_wheel --project tensorflow_io_gcs_filesystem
ls dist

它应该输出一个类似于这样的文件名。
tensorflow_io-0.31.0-cp39-cp39-macosx_11_0_arm64.whl
tensorflow_io_gcs_filesystem-0.31.0-cp39-cp39-macosx_11_0_arm64.whl

然后你可以安装这个wheel文件:

pip install wheel
python3 -m pip install --no-deps dist/tensorflow_io-0.31.0-cp39-cp39-macosx_11_0_arm64.whl
python3 -m pip install --no-deps dist/tensorflow_io_gcs_filesystem-0.31.0-cp39-cp39-macosx_11_0_arm64.whl

请确保将.whl文件更改为您的特定版本。

3
如果其他答案都失败了,试试这个。
git clone https://github.com/tensorflow/io
cd io
python setup.py build
python setup.py install

对我来说很有效。MacBook Pro M1 - Andrés Mauricio Gómez

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接