Conda environments give TensorFlow projects their own Python interpreter, pip entry point, and package directories. That separation matters when notebooks, training jobs, and other machine-learning projects need different versions of TensorFlow, Keras, NumPy, or supporting libraries.
TensorFlow is still installed from the official PyPI package in this workflow. Conda creates and activates the environment, while python -m pip install tensorflow installs the TensorFlow wheel inside that active environment instead of resolving the framework from Conda channels.
Python 3.12 is a conservative target for a new TensorFlow environment because it stays inside TensorFlow's supported wheel range and is widely available through Conda. Use Linux or WSL2 for current NVIDIA GPU work; native Windows GPU support ended with TensorFlow 2.10, and official macOS installs are CPU-only.
$ conda create --yes --name tf python=3.12 pip Collecting package metadata (repodata.json): done Solving environment: done ##### snipped ##### Preparing transaction: done Verifying transaction: done Executing transaction: done
The --yes option accepts Conda's package plan without an interactive prompt. Omit it when you want to review the package list before the environment is created.
$ conda activate tf (tf) $
(tf) $ python --version Python 3.12.13
(tf) $ python -m pip --version pip 26.1.2 from /home/user/miniforge3/envs/tf/lib/python3.12/site-packages/pip (python 3.12)
The path should include /envs/tf/ before the site-packages directory. If it points outside the Conda environment, reactivate the environment before continuing.
(tf) $ python -m pip install --upgrade pip Requirement already satisfied: pip in /home/user/miniforge3/envs/tf/lib/python3.12/site-packages (26.1.2)
This upgrades only the active tf environment, not the base Conda environment or the system Python installation.
(tf) $ python -m pip install tensorflow Collecting tensorflow ##### snipped ##### Successfully installed tensorflow-2.21.0
TensorFlow's install docs recommend pip for the tensorflow package because TensorFlow is officially released to PyPI, not as the latest stable Conda package. For current Linux or WSL2 GPU systems, install tensorflow[and-cuda] instead of tensorflow after the NVIDIA driver is working.
Related: How to enable GPU acceleration in TensorFlow
(tf) $ python -c "import tensorflow as tf; print(tf.__version__); print(tf.reduce_sum(tf.constant([1, 2, 3])).numpy())" 2.21.0 6
A printed TensorFlow version plus the numeric tensor result confirms that the package imports and executes inside the active Conda environment.
Related: How to check the TensorFlow version