# How to Install Keras Using pip install keras: Complete TensorFlow Setup Guide

> Easily install Keras with pip install keras for TensorFlow setup. Get a unified deep learning environment with Keras as the high-level API integrated into TensorFlow.

- Repository: [Keras/keras](https://github.com/keras-team/keras)
- Tags: getting-started
- Published: 2026-02-14

---

**Running `pip install keras` automatically installs TensorFlow and its dependencies, creating a unified deep learning environment where Keras serves as the high-level API integrated directly into TensorFlow's runtime.**

When you execute this command from the **keras-team/keras** repository distribution, the installer resolves a specific dependency chain defined in [`setup.cfg`](https://github.com/keras-team/keras/blob/main/setup.cfg) and pulls in the core TensorFlow engine along with preprocessing utilities and serialization libraries required for production model development.


## What `pip install keras` Installs Under the Hood

According to the **keras-team/keras** source code, the [`setup.cfg`](https://github.com/keras-team/keras/blob/main/setup.cfg) file declares **tensorflow** as the primary runtime dependency. When you run `pip install keras`, the package manager downloads and installs the following components:

- **tensorflow**: The core engine providing tensors, automatic differentiation, and execution runtime. Keras layers, models, and callbacks are built on top of this foundation.
- **keras-preprocessing**: Legacy utilities including `ImageDataGenerator` and `Tokenizer` that were split from the core repository.
- **pyyaml**, **h5py**, **numpy**, **requests**, **protobuf**: Required for model saving/loading, configuration parsing, and low-level I/O operations.

The dependency resolution process creates a clean installation matching your operating system, Python version, and hardware architecture (CPU-only by default).


### Version Synchronization Between Keras and TensorFlow

The Keras package maintains tight version coupling with TensorFlow. As implemented in the dependency specifications in [`setup.cfg`](https://github.com/keras-team/keras/blob/main/setup.cfg), installing `tensorflow==2.13.0` automatically provides `keras==2.13.0` under the hood. This synchronization guarantees API compatibility across callbacks, serialization formats, and training utilities implemented in `keras/src/engine/`.


## Step-by-Step Installation Process

Follow these steps to create an isolated environment and install Keras with all dependencies.


### 1. Create a Virtual Environment

Creating a clean virtual environment prevents conflicts between TensorFlow's heavy binary and other Python packages:

```bash
python -m venv keras-env
source keras-env/bin/activate  # On Windows: .\keras-env\Scripts\activate

pip install --upgrade pip

```


### 2. Install Keras

With the environment activated, run the installation command:

```bash
pip install keras

```

The installer downloads the pre-built TensorFlow wheel defined in the repository's [`requirements.txt`](https://github.com/keras-team/keras/blob/main/requirements.txt) and [`setup.cfg`](https://github.com/keras-team/keras/blob/main/setup.cfg), matching your platform without requiring separate TensorFlow installation. Optional extras like GPU-accelerated builds are only installed if explicitly requested.


### 3. Verify the Installation

Confirm that both packages load correctly and share synchronized versions:

```python
import tensorflow as tf
import keras

print(f"TensorFlow version: {tf.__version__}")
print(f"Keras version: {keras.__version__}")

# Access Keras through TensorFlow

print(tf.keras.__doc__)

```


## Building Your First Neural Network

Once installed via `pip install keras`, you can immediately start building models using the public API exposed in [`keras/__init__.py`](https://github.com/keras-team/keras/blob/main/keras/__init__.py) and implemented in `keras/src/engine/` and `keras/src/layers/`:

```python
from keras import layers, models
import numpy as np

# Define a sequential model

model = models.Sequential([
    layers.Dense(64, activation="relu", input_shape=(20,)),
    layers.Dense(10, activation="softmax")
])

# Compile with optimizer and loss function

model.compile(
    optimizer="adam",
    loss="sparse_categorical_crossentropy",
    metrics=["accuracy"]
)

# Generate dummy data for testing

x = np.random.random((100, 20))
y = np.random.randint(10, size=(100,))

# Train the model

model.fit(x, y, epochs=5, batch_size=32)

```

This example utilizes the core training loop implemented in [`keras/src/engine/training.py`](https://github.com/keras-team/keras/blob/main/keras/src/engine/training.py) and layer definitions in [`keras/src/layers/core/dense.py`](https://github.com/keras-team/keras/blob/main/keras/src/layers/core/dense.py).


## GPU Support Configuration

By default, `pip install keras` provides the CPU-only TensorFlow build. For TensorFlow 2.10 and later, GPU support is included in the standard `tensorflow` package automatically pulled by the Keras installer, provided you have NVIDIA CUDA and cuDNN libraries installed on your system.

If you are using legacy TensorFlow versions below 2.10:

```bash
pip uninstall tensorflow
pip install tensorflow-gpu
pip install keras

```

**Note**: The separate `tensorflow-gpu` package is deprecated as of TensorFlow 2.10. The standard `pip install keras` workflow is sufficient for GPU-accelerated training on modern versions when system drivers are properly configured.


## Summary

- **`pip install keras` installs TensorFlow automatically** as declared in the [`setup.cfg`](https://github.com/keras-team/keras/blob/main/setup.cfg) dependency chain, eliminating the need for separate TensorFlow installation.
- **Versions are synchronized** between Keras and TensorFlow (e.g., TF 2.13.0 provides Keras 2.13.0), ensuring API compatibility for callbacks and serialization.
- **Key files** including [`keras/__init__.py`](https://github.com/keras-team/keras/blob/main/keras/__init__.py) expose the public API while `keras/src/engine/` contains the core training logic and `keras/src/layers/` defines built-in layers.
- **GPU support** is available in TensorFlow 2.10+ without requiring separate package installation, though CUDA libraries must be present on the system.
- **Alternative**: For advanced use cases requiring only the high-level API without TensorFlow, the `keras-core` package exists, but this diverges from the standard `pip install keras` workflow.


## Frequently Asked Questions


### Does `pip install keras` install TensorFlow automatically?

Yes. According to the dependency specifications in the **keras-team/keras** repository's [`setup.cfg`](https://github.com/keras-team/keras/blob/main/setup.cfg), the `keras` package declares **tensorflow** as a mandatory runtime dependency. When you run `pip install keras`, the package manager automatically resolves and installs the compatible TensorFlow version, along with supporting libraries like `keras-preprocessing`, `h5py`, and `pyyaml`.


### Why do Keras and TensorFlow versions always match?

The Keras package maintains tight coupling with TensorFlow releases. As defined in the repository's dependency pins, the Keras version number mirrors the TensorFlow version (e.g., installing `tensorflow==2.13.0` provides `keras==2.13.0`). This synchronization prevents API mismatches between the high-level Keras interface in [`keras/__init__.py`](https://github.com/keras-team/keras/blob/main/keras/__init__.py) and the underlying TensorFlow runtime engine.


### How do I install Keras with GPU support?

For TensorFlow 2.10 and later, GPU support is included in the standard `tensorflow` package that `pip install keras` automatically pulls. You only need to ensure that NVIDIA CUDA and cuDNN libraries are installed on your system. For older TensorFlow versions, you could explicitly install `tensorflow-gpu`, though this approach is now deprecated in favor of the unified package structure.


### What is the difference between `keras` and `keras-core` packages?

The `keras` package (installed via `pip install keras`) includes TensorFlow as a backend dependency and represents the standard, production-ready distribution maintained by **keras-team/keras**. The `keras-core` package provides the high-level Keras API without bundling TensorFlow, intended for advanced users implementing custom backends or specialized execution environments. Most users should stick with `pip install keras` for standard deep learning workflows.