Post

Replies

Boosts

Views

Activity

Reply to Error when importing TensorFlow
I had the same problem. What solved it for me was to use python -m pip instead of pip install and do sanity checks after every line, ie which python and python -c 'import tensorflow' at earliest point possible. Example, starting from a new environment: conda create --name test-env -y python=3.8 conda activate test-env which python # make note and compare for later conda install -c apple -y tensorflow-deps which python # should remain same python -m pip install tensorflow-macos # notice the python -m pip variant which python # should remain same python -c 'import tensorflow' # an empty output should indicate successful import python -m pip install tensorflow-metal which python # should remain same python -c 'import tensorflow' # should still work ... Continue like this for every conda and pip package. For me, the python path changed after a call to pip install ..., which ultimately caused the issue while importing tensorflow.
Oct ’22