Need a discount on popular programming courses? Find them here. View offers

Simran Kaur Arora | 15 Dec, 2022

How To Install TensorFlow?

In simple words, TensorFlow is an open-source library for numerical computation, which is used to enhance the convenience and ease in machine learning, and it is an entirely Python friendly library. TensorFlow can run and train deep neural networks for image recognition, for handwritten digit classification, recurrent neural networks, word embeddings, and sequence-to-sequence models for natural language processing, PDE (partial differential equation) and machine translation. Most importantly, it supports production prediction at scale with exact models that are used for the training.

TensorflowFigure 1 TensorFlow logo

Five main use cases of TensorFlow

  • This technology is used for automatic image recognition systems because it consists of algorithms to identify shapes for modeling purposes.
  • Voice and sound recognition process can be done through the TensorFlow, and it is also used for sentiment analysis or flaw detection.
  • TensorFlow helps to improve the text-based recognition technology, and the best example is Google that supports various languages and the capability to transfer the text from one language to another.
  • It is used for analyzing the data and separating the meaningful states of it, and the best example of this use case is online streaming platforms (Netflix, YouTube), it uses statistical data to provide the best user experiences.
  • TensorFlow is used for the video detection system, which means it is helpful for motion detection or real-time threat detection systems.

Installing TensorFlow

Before starting the process of installation, let's learn that TensorFlow supports multiple GPUs and CPUs. It means that the process of computations can be divided according to the devices to enhance the speed of the training with the help of parallelization. It can provide faster training by training algorithms.

There are two versions of TensorFlow available for the Windows user, and these versions are:

CPU supported TensorFlow: If the system does not run on the NVIDIA GPU, then the user has to install this version.

GPU supported TensorFlow: This version is used for faster computation and strong computational capacity. 

User can install TensorFlow on both Windows and macOS 

For Windows user process is:

  • Install Anaconda
  • Create a .yml file for installing dependencies
  • Use pip for adding the TensorFlow
  • Launch Jupyter Notebook

For macOS user process is:

  • Install Anaconda
  • Create a .yml file for installing dependencies
  • Launch Jupyter Notebook

So, for starting the TensorFlow installation process user have to install the Anaconda, hence here is the installation process for both macOS and Windows:  

Step 1: Install Anaconda in the device:

Download the Anaconda version 4.3.1 for the required system, and this version is essential for Python 3.6. Now you have to create .yml file to install TensorFlow, and the process is:

  • Locate the path of Anaconda
  • Set the working directory to Anaconda
  • Create the yml file (For macOS user)
  • Edit the yml file
  • Compile the yml file
  • Activate Anaconda
  • Install TensorFlow (it is only for Windows user)
Locating the Anaconda

For the installation of Anaconda, the user has to locate a path for it. 

Users can create a new anaconda environment, which includes the essential libraries.

For Windows

For the windows, the user can use the Anaconda type and Prompt:

C:\>where Anaconda

Anaconda Prompt

For macOS:

For the macOS device, the user can use the type and terminal:

The user has to create a new folder in the Anaconda, which contains Jupyter, TensorFlow, and ipython. There is a fast way to install libraries and software to write a.yml file.

Path of Anaconda

Step 2: Set and select the working directory

The user has to decide an appropriate directory in which the user wants to create a.yml file, and it will be located in the Anaconda.

For macOS:

For the macOS, the default working directory will be Users/USERNAME, path anaconda3, and the working directory are entirely identical. In the macOS devices, the latest folder will be shown right before the $, and the terminal will install the libraries in the working directory.

Users can change the path to cd PATH in case the path on the text editor does not match the working directory. It is essential to wrap the PATH as the 'PATH' because this can turn the working directory to PATH.  

directory to PATH

Open the terminal and type:

cd anaconda3

For Windows user (make sure that the folder placed before Anaconda3):

cd C:\Users\Admin\Anaconda3 

cd anaconda3

Step 3: Create the yml file for the device: 

The user has to create the yml file in the new working directory, and after the process installs the complete dependencies, the user has to run TensorFlow. At last, copy and then paste the code in the terminal. 

For macOS devices:

For the macOS users, the file name will appear in the anaconda3:  

'touch hello-tf.yml.'


For Windows devices:

The file name for the windows device is:


Windows Devices

Step 4: Edit the yml file

For macOS devices:

Users have to paste the given code in the terminal to edit the file because the yml file is ready to edit or macOS users can use the vim for editing the yml file.

vi hello-tf.yml

Edit the YML

User has to enter the edit mode to press the ESC:

Press i to edit
Press w to save
Press q! to quit

Write the above code in the edit mode and then press ESC followed by the:w

Vi Hello

Important: Two spaces are needed after each intent because the file is the case and also intend sensitive.

For macOS devices:

name: hello-tfdependencies:  

- python=3.6  

- jupyter 
- ipython 
- pandas 
- pip:      


Here is the code explanation for the above code:

name: hello-tf: Name of the yml file



pandas: Install Python version 3.6, Jupyter, Ipython, and pandas libraries

pip: Install a Python library Install TensorFlow from Google APIs.

Then, press the Esc key followed by the:q! to quit the edit mode.

Vi Hello Step - 2

For Windows devices

Notepad is enough for the Windows devices because it doesn't support the vim program 

notepad hello-tf.yml

Enter following into the file

name: hello-of dependencies:  

- python=3.6 
- jupyter 
- ipython 
- pandas

Here is the code explanation for the above code 

name: hello-tf: Name of the yml file



pandas: Install Python version 3.6, Jupyter, Ipython, and pandas libraries

It will automatically open the notepad; then, the user can edit the file from there.

Path Conda

Step 5: Compile the yml file

User can compile the .yml file with the given code:

conda env create -f hello-tf.yml

Note: the new environment is automatically created in the current users for Windows devices. This can take almost 1.1 GB of the hard disk.

1.1 GB of hard disk

For Windows user:

For Windows User

Step 6 Activate the conda environment

Now the user has two conda environments, and the user has created an isolated condo environment with the libraries the user will use during the tutorials. This is required practice because each and every machine learning project requires various libraries.

conda env list

Step 6 Activate the conda environment

For macOS devices:

source activate hello-tf

Source Activate

For Windows devices:

activate hello-tf

Users can easily check all of the dependencies that are in the same environment. This is essential because it allows Python to use TensorFlow and Jupyter from a similar environment, and in case users don't see the three, they are located in the same folder; then, the user has to start all over again.

For macOS user:

which Python
which jupyter
which ipython


pip install --upgrade TensorFlow

For Windows devices:

where Python
where jupyter
where ipython

Anaconda 3

It is clear that there are two python environments first one is the main one, and the other one is created on i.e., hello-tf.  

User has to install the Tensorflow with the following command:

pip install TensorFlow

pip install tensorflow

Launch Jupyter Notebook

This process is the same in both Windows and macOS

Users can open TensorFlow with the help of Jupyter.

Note: Users have to initialize the environment for opening the TensorFlow each time.

User can proceed as follow:

Activate hello-tf Conda environment
Open Jupyter
Import TensorFlow
Delete Notebook
Close Jupyter

Activate conda

For macOS devices:

source activate hello-tf

For Windows devices:

conda activate hello-tf

conda activate hello-tf

Open Jupyter

After that, the user can open Jupyter from the Terminal

jupyter Notebook

jupyter notebook

Web browser of the user's device should automatically open the following link, or the user can copy this link which is provided by the terminal. http://localhost:8888 

In the Jupyter Notebook, the user can see all of the files in the working directory. Users can click on the Python3 for creating the new Notebook, and this new Notebook will automatically save in the working directory.


Import Tensorflow

User can import TensorFlow with the tf alias, in the Notebook and then the user can click to run as a new cell is created below

import TensorFlow as tf

import tensorflow as tf

Artificial Intelligence - TensorFlow Machine Learning

Write the first code with TensorFlow.

hello = tf.constant('Hello, Guru99!')


A new tensor is created now. Users successfully install TensorFlow with Jupyter in the system.

install TensorFlow with Jupyter

Delete file:

Users can delete the file, which is named Untitled.ipynb inside Jupyter.

delete the file

Close Jupyter

There are two ways available to close the Jupyter. The first one is directly closed from the Notebook, and the second one is through the terminal or Anaconda Prompt.

From the Jupyter

Click on the logout in the main panel of Jupyter Notebook:

main panel of Jupyter Notebook

Users will automatically be redirected to the logout page.

log out page

From the terminal

Select the Anaconda prompt or terminal and run twice ctrl+c.

ctrl+c to confirm

The first time users do ctrl+c and users have to conform regarding the shutdown of the Notebook by repeating ctrl+c to confirm.

The user has successfully logged out.


TensorFlow is a widely developing and beneficial technology at the same time, and it is essential to follow every single step to install the TensorFlow in both Windows and macOS devices. The installation process and coding are different for both OS, and the above steps hold all of the information that is required to install TensorFlow.

People are also reading:


Subscribe to our monthly newsletter

Welcome to the club and Thank you for subscribing!

By Simran Kaur Arora

Simran works at Hackr as a technical writer. The graduate in MS Computer Science from the well known CS hub, aka Silicon Valley, is also an editor of the website. She enjoys writing about any tech topic, including programming, algorithms, cloud, data science, and AI. Traveling, sketching, and gardening are the hobbies that interest her.

View all post by the author

Disclosure: is supported by its audience. When you purchase through links on our site, we may earn an affiliate commission.

In this article

Learn More

Please login to leave comments