How to Install Keras in Jupyter Notebook?

Installing Keras in a Jupyter Notebook environment is a straightforward process that involves a few simple steps. Before we delve into the installation procedure, let’s understand what Keras is and why it’s a popular choice for deep learning projects.

Understanding Keras:

Keras is an open-source deep learning framework written in Python that provides a high-level API for building and training neural networks. It’s known for its user-friendly interface, simplicity, and flexibility, making it an ideal choice for beginners and experts alike. Keras allows you to quickly prototype and experiment with different neural network architectures while abstracting away the complexities of low-level implementation details.

Now, let’s proceed with the steps to install Keras in a Jupyter Notebook environment:

Step 1: Install Python:

First, ensure that you have Python installed on your system. You can download and install Python from the official Python website ( or use a package manager like Anaconda, which comes with Python and many useful packages pre-installed.

Step 2: Create a Virtual Environment (Optional):

While not strictly necessary, creating a virtual environment is considered a best practice to isolate your project dependencies. To create a virtual environment, open a terminal or command prompt and execute the following command:

python -m venv myenv

Replace “myenv” with the name you want to give to your virtual environment.

Activate the virtual environment by running the appropriate command based on your operating system:

  • On Windows:


  • On macOS/Linux:

bashCopy code

source myenv/bin/activate

Step 3: Install Keras:

With the virtual environment activated (if you’re using one), you can now install Keras using the pip package manager. Run the following command in your terminal or command prompt:

pip install keras

This command will install the latest version of Keras along with its dependencies.

Step 4: Install TensorFlow (Optional):

Keras relies on a backend engine for computation, and TensorFlow is the default backend for Keras. If you haven’t already installed TensorFlow, you can do so by running the following command:

pip install tensorflow

Alternatively, if you prefer to use another backend like Theano or Microsoft Cognitive Toolkit (CNTK), you can install them separately and configure Keras to use the desired backend.

Step 5: Install Jupyter Notebook (if not already installed):

If you haven’t already installed Jupyter Notebook, you can do so using pip:

pip install jupyterlab

This command will install Jupyter Notebook along with its dependencies.

Step 6: Launch Jupyter Notebook:

Once Keras and Jupyter Notebook are installed, you can launch Jupyter Notebook by running the following command in your terminal or command prompt:

jupyter notebook

This command will start the Jupyter Notebook server and open your default web browser to the Jupyter Notebook dashboard.

Step 7: Create a New Notebook:

From the Jupyter Notebook dashboard, click on the “New” button in the top right corner and select “Python 3” to create a new Python notebook.

Step 8: Import Keras and Start Using:

In your new notebook, you can import Keras by adding the following code cell and executing it:

import keras

Now you’re ready to start using Keras in your Jupyter Notebook!

Verifying the Installation:

To verify that Keras is installed correctly, you can run the following code cell in your notebook:


This will print the version of Keras installed in your environment.

Final Conclusion on How to Install Keras in Jupyter Notebook?

In this guide, we’ve covered the steps to install Keras in a Jupyter Notebook environment using pip.

By following these steps, you can set up Keras and start experimenting with deep-learning models in your Jupyter Notebook. Remember to activate a virtual environment if you choose to use one, and always ensure that your dependencies are installed correctly to avoid conflicts with other projects.

With Keras installed, you’re now equipped to explore the vast possibilities of deep learning within the Jupyter Notebook environment.


No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *