Open In App
Related Articles

Install Tensorflow on MacOS

Improve Article
Save Article
Like Article

TensorFlow is an open-source software library developed by the Google brain team. It widely used to implement deep learning models which helps in solving real world problems. In this article, we learn how to install TensorFlow on macOS using Homebrew.


  1. Python 3.6–3.8
  2. macOS 10.12.6 (Sierra) or later (no GPU support)

Installing TensorFlow:

Step 1: Verify the python version:

$ python3 --version

Step 2: Verify if the brew is installed:

$ brew --version

Step 3: Create the virtual environment:

$ brew install virtualenv

Step 4: After creating a new virtual environment, create a  ./pythonenv directory to hold it.

$ virtualenv --system-site-packages -p python3 ./pythonenv

Step 5: Go inside ./pythonenv

$ cd ./pythonenv

Step 6: Activate the virtual environment

source bin/activate

Step 7: Install TensorFlow.

brew install tensorflow

Step 8: Create a new folder inside /pythonenv called tfdemo. Create a new file inside tfdemo called

Step 9: Run the file:

$ python3


# importing tensorflow
import tensorflow as tf
# creating nodes in computation graph
node1 = tf.constant(3, dtype = tf.int32)
node2 = tf.constant(5, dtype = tf.int32)
node3 = tf.add(node1, node2)
# create tensorflow session object
sess = tf.Session()
# evaluating node3 and printing the result
print("Sum of node1 and node2 is:",
# closing the session


Last Updated : 23 May, 2021
Like Article
Save Article
Similar Reads
Related Tutorials