首页 > 解决方案 > 无法在 Mac M1 上安装 TensorFlow。安装过程中遇到错误

问题描述

我对编程很陌生,我正在尝试在我的机器上安装 tensorflow。我的 Macbook 有 M1 芯片,当你想要 tensorflow 时,它显然会让生活变得艰难。我在 youtube 上跟着一个人,我被困在最后一步。我设置了一个 anaconda 虚拟环境,当我运行这个安装文件时它甚至说它是成功的install_venv.sh(来自 MacOS tensorflow/github 页面...... https://github.com/apple/tensorflow_macos/releases)

但是,当我运行import tensorflow as tf它时,它会引发此错误(对不起,长度,包括整个错误,所以我不会错过任何东西)请有人帮忙,也许教我为什么会这样。

我一直试图让 tensorflow 工作几个小时!

Traceback (most recent call last):
  File "/Users/jacobholmes/opt/anaconda3/envs/test_opencv/lib/python3.8/site-packages/tensorflow/python/pywrap_tensorflow.py", line 64, in <module>
    from tensorflow.python._pywrap_tensorflow_internal import *
ImportError: dlopen(/Users/jacobholmes/opt/anaconda3/envs/test_opencv/lib/python3.8/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so, 6): no suitable image found.  Did find:
    /Users/jacobholmes/opt/anaconda3/envs/test_opencv/lib/python3.8/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so: mach-o, but wrong architecture
    /Users/jacobholmes/opt/anaconda3/envs/test_opencv/lib/python3.8/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so: mach-o, but wrong architecture

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/jacobholmes/opt/anaconda3/envs/test_opencv/lib/python3.8/site-packages/tensorflow/__init__.py", line 41, in <module>
    from tensorflow.python.tools import module_util as _module_util
  File "/Users/jacobholmes/opt/anaconda3/envs/test_opencv/lib/python3.8/site-packages/tensorflow/python/__init__.py", line 39, in <module>
    from tensorflow.python import pywrap_tensorflow as _pywrap_tensorflow
  File "/Users/jacobholmes/opt/anaconda3/envs/test_opencv/lib/python3.8/site-packages/tensorflow/python/pywrap_tensorflow.py", line 83, in <module>
    raise ImportError(msg)
ImportError: Traceback (most recent call last):
  File "/Users/jacobholmes/opt/anaconda3/envs/test_opencv/lib/python3.8/site-packages/tensorflow/python/pywrap_tensorflow.py", line 64, in <module>
    from tensorflow.python._pywrap_tensorflow_internal import *
ImportError: dlopen(/Users/jacobholmes/opt/anaconda3/envs/test_opencv/lib/python3.8/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so, 6): no suitable image found.  Did find:
    /Users/jacobholmes/opt/anaconda3/envs/test_opencv/lib/python3.8/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so: mach-o, but wrong architecture
    /Users/jacobholmes/opt/anaconda3/envs/test_opencv/lib/python3.8/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so: mach-o, but wrong architecture


Failed to load the native TensorFlow runtime.

See https://www.tensorflow.org/install/errors

for some common reasons and solutions.  Include the entire stack trace
above this error message when asking for help.
>>> /Users/jacobholmes/Downloads/tensorflow_macos/ins

标签: pythonmacostensorflow

解决方案


推荐阅读