A Python project needs the TensorFlow package in the same environment that runs notebooks, training scripts, or inference code. The official PyPI wheel keeps the install inside a selected Python environment without moving the project to a separate Conda workflow.
Running pip through python -m pip ties the package operation to the interpreter selected by the shell or virtual environment. Confirm the interpreter first, because TensorFlow wheels target a narrower set of CPython versions than many workstation defaults.
The plain tensorflow package is the CPU install path for supported platforms. Use tensorflow[and-cuda] only on Linux or WSL2 systems where the NVIDIA driver already works; native Windows GPU support is limited to legacy TensorFlow releases, native Windows CPU installs still need the Microsoft Visual C++ Redistributable, and current official macOS wheels are CPU-only for Apple Silicon.
$ source ~/venvs/tf/bin/activate (tf) $
On Windows, run the equivalent virtual environment activation command or use a matching Python Launcher selector such as py -3.12 -m pip for the remaining pip commands.
(tf) $ python --version Python 3.12.13
Current TensorFlow 2.21 wheels cover CPython 3.10 through 3.13 on supported platforms. Switch environments before installing if this command reports Python 3.14 or newer.
(tf) $ python -m pip --version pip 26.1.2 from /home/user/venvs/tf/lib/python3.12/site-packages/pip (python 3.12)
The path should belong to the environment you activated. A system path means the install would modify a different Python package set.
(tf) $ python -m pip install --upgrade pip Requirement already satisfied: pip in /home/user/venvs/tf/lib/python3.12/site-packages (25.0.1) Collecting pip ##### snipped ##### Successfully installed pip-26.1.2
(tf) $ python -m pip install tensorflow Collecting tensorflow Downloading tensorflow-2.21.0-cp312-cp312-manylinux_2_27_aarch64.whl.metadata (4.4 kB) ##### snipped ##### Successfully installed tensorflow-2.21.0
The wheel tag, dependency versions, and CPU architecture can differ by platform. On supported Linux or WSL2 GPU hosts, install tensorflow[and-cuda] instead after confirming the NVIDIA driver works.
Related: How to enable GPU acceleration in TensorFlow
(tf) $ python -c "import tensorflow as tf; print(tf.__version__)" 2.21.0
Related: How to check the TensorFlow version
(tf) $ python -c "import tensorflow as tf; print(tf.reduce_sum(tf.ones([1000, 1000])))" tf.Tensor(1e+06, shape=(), dtype=float32)
The tensor result confirms that the package imports and executes a TensorFlow operation in the active environment.