TensorFlow
Anaconda
Installation Guide
Version Control
Machine Learning

Install TensorFlow with specific version on Anaconda

Master System Design with Codemia

Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.

Introduction

The safest modern way to install a specific TensorFlow version with Anaconda is to use conda for the environment and pip for the TensorFlow package itself. That combination gives you environment isolation without depending on conda to provide the official TensorFlow build. In practice, you create a fresh conda environment, activate it, and then install the exact TensorFlow version with pip install tensorflow==....

Create A Clean Conda Environment

Start by creating an environment with a Python version that is compatible with the TensorFlow release you want.

bash
conda create -n tf216 python=3.10
conda activate tf216

Using a dedicated environment avoids version conflicts with existing packages.

Before choosing a Python version, check the TensorFlow release notes or install docs for the release you want. TensorFlow version constraints and Python support windows do change over time.

Install The Exact TensorFlow Version With Pip

Once the conda environment is active, upgrade pip and install the version you want.

bash
python -m pip install --upgrade pip
pip install tensorflow==2.16.1

That pins TensorFlow to the specific version instead of taking the latest available release.

If your platform and TensorFlow version support the extra package set for NVIDIA GPU dependencies, you may use the GPU-oriented extra package form when appropriate.

bash
pip install "tensorflow[and-cuda]==2.16.1"

Whether that extra is suitable depends on your operating system and TensorFlow release. CPU-only installs are usually simpler if you do not need GPU acceleration.

Verify The Installation

After installation, confirm that Python is importing the version you expected.

bash
python -c "import tensorflow as tf; print(tf.__version__)"

For a successful pinned install, the printed version should match exactly.

If you are testing GPU availability, you can also check visible devices.

bash
python -c "import tensorflow as tf; print(tf.config.list_physical_devices('GPU'))"

Why Pip Inside Conda Is Usually The Right Approach

The important distinction is that Anaconda is managing the environment, while pip is installing the official TensorFlow package. That matters because TensorFlow releases are officially published to PyPI, and conda packages may lag or differ.

So the practical workflow is:

  • use conda to isolate Python and dependencies
  • use pip to install the official TensorFlow wheel
  • pin the exact version in your environment setup instructions

That gives you reproducibility without depending on unofficial or outdated package builds.

Record The Version For Reproducibility

If the environment needs to be recreated later, save the relevant dependency versions.

bash
pip freeze | grep tensorflow
conda env export > environment.yml

environment.yml captures the conda environment, while the pip entry ensures the TensorFlow version is explicit.

Common Pitfalls

The most common mistake is trying to mix arbitrary conda TensorFlow packages and pip TensorFlow packages in the same environment without a clear reason. That often leads to version confusion.

Another issue is choosing a Python version that the target TensorFlow release does not support. If installation fails unexpectedly, check compatibility first.

It is also easy to forget to activate the environment before installing. Then TensorFlow ends up in the wrong Python environment and appears to be missing later.

Finally, GPU support has more prerequisites than CPU support. If all you need is CPU training or inference, keep the setup simple and verify that first.

Summary

  • Use conda to create the environment and pip to install the official TensorFlow package.
  • Pin the exact TensorFlow version with pip install tensorflow==....
  • Choose a Python version that matches the TensorFlow release you want.
  • Verify the install immediately with import tensorflow as tf and tf.__version__.
  • Keep GPU installation separate from the basic CPU workflow unless you truly need it.

Course illustration
Course illustration

All Rights Reserved.