Simran Kaur Arora | 08 Aug, 2023

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.

Where Is TensorFlow Used?

Before we dive into our guide on how to install TensorFlow, let’s take a moment to summarize some of the most common reasons to use this open-source machine learning library.

  • Computer Vision: One of the most common use cases for TensorFlow involves popular tasks like image classification, object detection, and facial recognition.
  • Natural Language Processing (NLP): TensorFlow can be used for sentiment analysis, text classification, entity recognition, language translation, and text generation.
  • Time Series Analysis: TensorFlow can be used for time series forecasting and analysis in fields like finance and meteorology.
  • Speech Recognition: A popular use case for TensorFlow is to to develop automatic speech recognition (ASR) systems for voice-controlled interfaces and virtual assistants.
  • Healthcare: TensorFlow is well-suited to to medical image analysis, disease diagnosis, drug discovery, and predicting patient outcomes.
  • Recommendation Systems: A natural use case for TensorFlow is to build recommendation systems based on user behavior.
  • Generative Models: TensorFlow can be used to build Generative Adversarial Networks (GANs) and Variational Autoencoders (VAEs) to help generate realistic images, audio, and video.

How To Install TensorFlow

Let’s look at the general steps to install TensorFlow using the Python package manager Pip. And of course, make sure that you already have a stable version of Python installed on your system. 

We'd also recommend using a virtual environment, as this is a great way to manage Python packages on a project-by-project basis.

1. Create a Virtual Environment (Optional):

This step is optional, but we'd highly recommend getting into the habit of using virtual environments for different Python projects. The easiest ways to do this are with virtualenv or with the built-in venv module that comes bundled with Python 3.

Take a look at the two methods below, and just remember to replace <env_name> with the name you'd like to use for your new virtual environment.

pip install virtualenv
virtualenv <env_name>
source <env_name>/bin/activate  # On Windows, use: <env_name>\Scripts\activate
python3 -m venv <env_name>
source <env_name>/bin/activate  # On Windows, use: <env_name>\Scripts\activate

2. Install TensorFlow:

After you have your virtual environment activated, you're now ready to install TensorFlow with pip. To begin, if you just plan to use the CPU version of TensorFlow (which is usually sufficient for most tasks), run the command shown below:

pip install tensorflow

On the other hand, if you have a GPU that's compatible with TensorFlow along with CUDA setup on your system, you do have the option of using the GPU-accelerated version of TensorFlow. To install this, use the command shown below:

pip install tensorflow-gpu

3. Verify the Installation

After the pip command finishes installing TensorFlow, you can verify that the install completed correctly by creating a new Python script and checking the version as shown below. If the install completed successfully, this should print out the version number of TensorFlow that you installed within your virtual environment.

import tensorflow as tf

Important note: remember to activate your virtual environment every time you want to work on a project with TensorFlow, as this will keep your package installations isolated from your other Python projects. 


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:


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

Subscribe to our Newsletter for Articles, News, & Jobs.

I accept the Terms and Conditions.

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