无法在 Mac M1 上导入 TensorFlow

Cannot import TensorFlow on Mac M1

我正在尝试 运行 shell Mac OS M1 上的脚本,但它一直给我错误:

ModuleNotFoundError: No module named 'tensorflow'

我按照此处的说明操作:https://caffeinedev.medium.com/how-to-install-tensorflow-on-m1-mac-8e9b91d93706

尽管我现在可以在python中手动导入它:

(mlp) sarah@Air-Sarah AIR % python 
Python 3.8.11 (default, Aug 16 2021, 12:04:33) 
[Clang 12.0.0 ] :: Anaconda, Inc. on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
>>> tf.__version__
'2.8.0'

我在 shell 中的错误仍然存​​在。

我也试过用https://github.com/apple/tensorflow_macos安装它。没有任何变化。

还有 它说 Python 版本必须是 3.8 才能导入 TensorFlow,但我的是 3.8。

我还能做什么?

我已经能够解决此问题 guide