在用pip导入tensorflow时发现报错

ERROR: Could not find a version that satisfies the requirement tensorflow (from versions: none)
ERROR: No matching distribution found for tensorflow

报错详情

不同于tensorflow官网给出的方案:https://tensorflow.google.cn/install/pip?hl=zh-cn#旧版%20TensorFlow

$ pip install --upgrade tensorflow

首先需要确认满足以下条件

  • 配备苹果芯片或AMD GPU的Mac电脑
  • macOS 12.0或更高版本
  • Python 3.8或更高版本
  • Xcode命令行工具:xcode-select --install

M系列芯片需要用另一个命令进行安装,步骤如下
1.安装基础的TensorFlow

$ pip install tensorflow-macos

安装基础的TensorFlow

2.安装tensorflow-metal插件

$ pip install tensorflow-metal

安装tensorflow-metal插件

以上操作都是在pycharm的terminal中运行的
更详细的说明可以参考苹果官网:https://developer.apple.com/metal/tensorflow-plugin/
如果不行的话可以检查一下自己的pip版本

更多推荐