Can´t use tensorflow on Macbook Air M1

Hello Community :)

I tried to install tensorflow on my Macbook Air M1 (MAC OS 12.1). I followed these steps: https://developer.apple.com/metal/tensorflow-plugin/

But when I try to import tensorflow on python in my shell I geht this error:

(base) MacBook-Air:~ rafaelparzeller$ python

Python 3.9.7 | packaged by conda-forge | (default, Sep 29 2021, 19:24:02) 

[Clang 11.1.0 ] on darwin

Type "help", "copyright", "credits" or "license" for more information.

import tensorflow as tf

Traceback (most recent call last):

  File "/Users/rafaelparzeller/miniforge3/lib/python3.9/site-packages/numpy/core/init.py", line 22, in

    from . import multiarray

  File "/Users/rafaelparzeller/miniforge3/lib/python3.9/site-packages/numpy/core/multiarray.py", line 12, in

    from . import overrides

  File "/Users/rafaelparzeller/miniforge3/lib/python3.9/site-packages/numpy/core/overrides.py", line 7, in

    from numpy.core._multiarray_umath import (

ImportError: dlopen(/Users/rafaelparzeller/miniforge3/lib/python3.9/site-packages/numpy/core/_multiarray_umath.cpython-39-darwin.so, 0x0002): Library not loaded: @rpath/libcblas.3.dylib

  Referenced from: /Users/rafaelparzeller/miniforge3/lib/python3.9/site-packages/numpy/core/_multiarray_umath.cpython-39-darwin.so

  Reason: tried: '/Users/rafaelparzeller/miniforge3/lib/libcblas.3.dylib' (no such file), '/Users/rafaelparzeller/miniforge3/lib/libcblas.3.dylib' (no such file), '/Users/rafaelparzeller/miniforge3/lib/python3.9/site-packages/numpy/core/../../../../libcblas.3.dylib' (no such file), '/Users/rafaelparzeller/miniforge3/lib/libcblas.3.dylib' (no such file), '/Users/rafaelparzeller/miniforge3/lib/libcblas.3.dylib' (no such file), '/Users/rafaelparzeller/miniforge3/lib/python3.9/site-packages/numpy/core/../../../../libcblas.3.dylib' (no such file), '/Users/rafaelparzeller/miniforge3/lib/libcblas.3.dylib' (no such file), '/Users/rafaelparzeller/miniforge3/bin/../lib/libcblas.3.dylib' (no such file), '/Users/rafaelparzeller/miniforge3/lib/libcblas.3.dylib' (no such file), '/Users/rafaelparzeller/miniforge3/bin/../lib/libcblas.3.dylib' (no such file), '/usr/local/lib/libcblas.3.dylib' (no such file), '/usr/lib/libcblas.3.dylib' (no such file)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

  File "", line 1, in

  File "/Users/rafaelparzeller/miniforge3/lib/python3.9/site-packages/tensorflow/init.py", line 41, in

    from tensorflow.python.tools import module_util as _module_util

  File "/Users/rafaelparzeller/miniforge3/lib/python3.9/site-packages/tensorflow/python/init.py", line 41, in

    from tensorflow.python.eager import context

  File "/Users/rafaelparzeller/miniforge3/lib/python3.9/site-packages/tensorflow/python/eager/context.py", line 30, in

    import numpy as np

  File "/Users/rafaelparzeller/miniforge3/lib/python3.9/site-packages/numpy/init.py", line 140, in

    from . import core

  File "/Users/rafaelparzeller/miniforge3/lib/python3.9/site-packages/numpy/core/init.py", line 48, in

    raise ImportError(msg)

ImportError: 

IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!

Importing the numpy C-extensions failed. This error can happen for

many reasons, often due to issues with your setup or how NumPy was

installed.

We have compiled some common reasons and troubleshooting tips at:

    https://numpy.org/devdocs/user/troubleshooting-importerror.html

Please note and check the following:

  * The Python version is: Python3.9 from "/Users/rafaelparzeller/miniforge3/bin/python"

  * The NumPy version is: "1.19.5"

and make sure that they are the versions you expect.

Please carefully study the documentation linked above for further help.

Original error was: dlopen(/Users/rafaelparzeller/miniforge3/lib/python3.9/site-packages/numpy/core/_multiarray_umath.cpython-39-darwin.so, 0x0002): Library not loaded: @rpath/libcblas.3.dylib

  Referenced from: /Users/rafaelparzeller/miniforge3/lib/python3.9/site-packages/numpy/core/_multiarray_umath.cpython-39-darwin.so

  Reason: tried: '/Users/rafaelparzeller/miniforge3/lib/libcblas.3.dylib' (no such file), '/Users/rafaelparzeller/miniforge3/lib/libcblas.3.dylib' (no such file), '/Users/rafaelparzeller/miniforge3/lib/python3.9/site-packages/numpy/core/../../../../libcblas.3.dylib' (no such file), '/Users/rafaelparzeller/miniforge3/lib/libcblas.3.dylib' (no such file), '/Users/rafaelparzeller/miniforge3/lib/libcblas.3.dylib' (no such file), '/Users/rafaelparzeller/miniforge3/lib/python3.9/site-packages/numpy/core/../../../../libcblas.3.dylib' (no such file), '/Users/rafaelparzeller/miniforge3/lib/libcblas.3.dylib' (no such file), '/Users/rafaelparzeller/miniforge3/bin/../lib/libcblas.3.dylib' (no such file), '/Users/rafaelparzeller/miniforge3/lib/libcblas.3.dylib' (no such file), '/Users/rafaelparzeller/miniforge3/bin/../lib/libcblas.3.dylib' (no such file), '/usr/local/lib/libcblas.3.dylib' (no such file), '/usr/lib/libcblas.3.dylib' (no such file)

 

Was somebody able to fix this problem and how? :)

Accepted Reply

See this post, this should help, you have exactly the same problem : https://developer.apple.com/forums/thread/696693

Add a Comment

Replies

You need to install numpy. Use below commands if needed-

pip3 install Cython
pip3 install --no-binary :all: --no-use-pep517 numpy
pip3 install pandas
pip3 install ib_insync
  • It's on a M1. don't use pip when dealing with Tensorflow as it's suppose to be installed using miniforge3

Add a Comment

See this post, this should help, you have exactly the same problem : https://developer.apple.com/forums/thread/696693

Add a Comment