Are you wondering how to download and install TensorFlow and get it up and running to import in your Jupyter Notebook correctly?
Jupyter Notebook is an incredible open-source web tool that enables developers to streamline creating and sharing live code, equations, visualizations, and narrative text. Data scientists and machine learning researchers extensively use this tool to create reproducible workflows.
On the contrary, TensorFlow is an open-source software library primarily built for dataflow and differential programming across a wide spectrum of tasks such as machine learning, deep learning, and neural networks.
It is challenging for novice programmers to integrate TensorFlow into their Jupyter Notebook, so we have composed this guide which breaks down the process into tiny manageable chunks.
This post will discuss installing and running TensorFlow code within your Notebook environment.
Table of Contents
- Why You Should Install TensorFlow in Jupyter Notebook?
- Getting Started
- Steps to Download and Install TensorFlow In Jupyter Notebook
- 1. Download and Install Anaconda
- 2. Create A New Environment
- 3. Activate Your Environment
- 4. Install TensorFlow
- 5. Launch Jupyter Notebook
- 6. Create A New Notebook
- 7. Import TensorFlow
- 8. Verify the TensorFlow Installation
Why You Should Install TensorFlow in Jupyter Notebook?
Installing TensorFlow in Jupyter Notebook can be quite advantageous. This allows developers and machine learning specialists to run TensorFlow code directly within the notebook environment. This allows greater creative liberty because researchers can experiment with different models and techniques and visualize the results using interactive plots all in one place. This integration further simplifies the process of sharing your work with fellow developers.
Apart from this, integrating TensorFlow into your Jupyter Notebook can grant you access to a plethora of documentation that can prove to be instrumental in your success as a machine learning expert. TensorFlow offers a multitude of resources on its website, such as code samples, modules, and functions. The integration of TensorFlow in your Jupyter Notebook can not only allow you to help streamline your workflow. This results in a dynamic environment where you can easily develop, test, and deploy machine learning models.
Jupyter Notebooks have the additional benefit of being highly interactive. These books are your go-to place to manipulate and visualize data in real-time. Installing TensorFlow lets you integrate machine learning algorithms and models directly into your notebook. This allows for real-time feedback and critique on data and model performance.
Lastly, integrating the notebook environment with TensorFlow allows you to take advantage of several powerful tools and libraries available to the Python Ecosystem, such as NumPy, Pandas, and Matplotlib further enhances your chances of having success with machine learning models.
Getting Started
Before you can get started with installing TensorFlow on Jupyter Notebook, there are some prerequisites you need to be aware of:
- To install TensorFlow, you must have the latest version of Python installed on your device.
- In addition, your device must have a Windows, macOS, or Linux operating system because TensorFlow is only compatible with these systems.
- Lastly, you need to install pip on your device to install TensorFlow. It is a package manager for Python that is commonly used to install and manage packages.
With the prerequisites out of the way, let’s start with the tutorial.
Steps to Download and Install TensorFlow In Jupyter Notebook
1. Download and Install Anaconda
The first step in installing TensorFlow involves installing the latest version of Anaconda from their official site for your Operating System. Anaconda is a free, open-source distribution of R and Python. Its primary goal is to provide a comprehensive environment for machine learning and data science applications and to streamline the process of creating and deploying data-driven applications for developers.
Head over to the official site of Anaconda and download the latest version.
2. Create A New Environment
After installing Anaconda on your system, you must create a new environment for your TensorFlow installation.
- Launch Anaconda Navigator and press the “Environments” tab.
- Find the “create” button and click it to create a new environment
- Give your new environment a name (We will name our environment “tensorflow”)
- Select the Python Version you want to use and click the “Create” button
3. Activate Your Environment
- After successfully creating your environment, you must activate it to proceed. To do so, head back to the “Home” tab in Anaconda Navigator and select your environment from the drop-down menu.
- Then, click the “Play” button to open up a terminal. In the terminal, simply type the command to activate your environment:
conda activate tensorflow
4. Install TensorFlow
- Once your environment has been activated successfully, you can install TensorFlow by typing the following command in the terminal:
pip install tensorflow
- This will install the latest version of TensorFlow in your environment. But if you want to install a specific TensorFlow version, you can use the following command instead:
pip install tensorflow==<version>
- The
"<version>"
can easily be replaced with the version number that you wish to install, for instance (“2.3.0”)
5. Launch Jupyter Notebook
- Now that you have installed TensorFlow, you can launch Jupyter Notebook by entering the following command in the terminal:
jupyter notebook
- This will launch Jupyter Notebook in your default web browser.
6. Create A New Notebook
To create a new notebook, click the “New” button on the top right corner of the Jupyter Notebook homepage and select the Python version you installed.
7. Import TensorFlow
To start using TensorFlow smoothly, you must import it. Proceed by adding the following code to the first cell of your created notebook:
import tensorflow as tf
8. Verify the TensorFlow Installation
To verify if TensorFlow has been installed successfully, you can add the following code to the second cell of your notebook:
tf.__version__
This will return the version of TensorFlow that you have installed. This operation is successful if you are met with the version number you installed.
Final Thoughts
If you followed the steps mentioned in the guide above, we are sure that you can install TensorFlow in your Jupyter Notebook successfully. We hope that this tutorial was of aid in your
Journey of building machine learning models.
Lastly, let us know in the comments;
- Were you successful in installing TensorFlow in Jupyter Notebook using the steps above?
- Have you encountered any issues while installing TensorFlow on Jupyter Notebook, and were they addressed adequately in the article?
- Did you find using visual aids, such as screen clippings, helpful in understanding the installation procedure?
Feel free to share this guide with your fellow developers, and as usual, Happy Coding!