Reputation: 3738
After an OS update, I spent several hours installing Tensorflow 2.X on my Mac laptop running OS X Catalina (same problem with Big Sur or Mojave) but WITHOUT ANACONDA. I searched a lot finding only bits of the answer and finally found a solution that I would like to share to help other people.
I've got mainly two kind of problems: 1) “Operation not permitted” caused by zealous strengthening of security on the new Mac OS and 2) problem installing TensorFlow 2.X of the kind “ModuleNotFoundError: No module named 'tensorflow'“ caused by messy paths to Python libraries.
Upvotes: 0
Views: 2319
Reputation: 3738
First correct “Operation not permitted” by granting Terminal full disk access using “Security & Privacy” control panel in the system preferences. Find the details here.
Install TensorFlow 2.X on your Mac without using Anaconda (if that's what you want). inspiration from
2.1) Be sure to have XCode and its command line tools and pip3 installed
2.2) Install Python 3.8 using Brew (I think 3.9 is not compatible yet with TensorFlow)
> brew install [email protected]
> brew link --force [email protected]
2.3) Add symbolic link
> ln -s /usr/local/opt/[email protected]/bin/python3 /usr/local/bin/python3
2.4) Add PATH and compiler flags in the .zshrc file (or .bash_profile)
> echo 'export LDFLAGS="-L/usr/local/opt/[email protected]/lib"' >> ~/.zshrc
> echo 'export PKG_CONFIG_PATH="/usr/local/opt/[email protected]/lib/pkgconfig"' >> ~/.zshrc
> echo 'export PATH="/usr/local/bin:$PATH"' >> ~/.zshrc
> echo 'export PATH="/usr/local/bin:$PATH"' >> ~/.zshrc
> source .zshrc
2.5) Install cmake
> brew install cmake pkg-config wget
2.6) Install TensorFlow 2.X
> sudo pip3 install tensorflow
Upvotes: 1