Written and maintained by CASRAI Editorial Board
Last updated
TensorFlow is an open source machine learning library for research and production, according to its own overview page. Researchers use it to build and train models, most often through its Keras API, and the quickest way to install it for notebook work is to put it in the same Python environment as Jupyter, as shown below. This guide covers what it does, how to install it in a Jupyter notebook, how to check that the install worked, and what to record so your analysis can be reproduced. It sits alongside our general guide to machine learning in research.
What TensorFlow is used for in research
The TensorFlow overview describes the library as built for both research and production. For a researcher, three parts of that description matter in practice:
- Keras Sequential API. The overview says the best place to start is the user-friendly Keras sequential API, and its beginner quickstart is a “Hello, World!” notebook that uses it with
model.fit. - Keras functional and subclassing APIs. The overview points to these for more advanced research models.
- Other deployment targets. TensorFlow Lite is for deploying machine learning on mobile, microcontrollers and other edge devices; TensorFlow.js is for web machine learning applications in JavaScript. Most analysis work never needs either.
The official tutorials are Jupyter notebooks with a “Run in Google Colab” button, so you can try TensorFlow with no local setup before deciding whether to install it.
Install or access (official source only)
TensorFlow’s install page recommends pip and states that TensorFlow is officially released only to PyPI, so it advises against installing it with conda. The same page lists these system requirements (checked 2026-10-29):
- Ubuntu 16.04 or later (64-bit); macOS 12.0 or later (no GPU support); Windows native 7 or later (64-bit, no GPU support after TensorFlow 2.10); Windows 10 19044 or later through WSL2.
- pip 19.0 or later on Linux and Windows; pip 20.3 or later on macOS.
- On native Windows, the Microsoft Visual C++ Redistributable for Visual Studio 2015, 2017 and 2019.
- A supported Python version. The page’s wheel table lists the Python versions for each release, so check that table for your Python before installing, because Python 3.9 support has been dropped in current releases.
The page also notes that the binaries use AVX instructions, which may not run on older CPUs.
Step by step: install TensorFlow in a Jupyter notebook
The one rule that prevents most failures is to install TensorFlow and Jupyter into the same Python environment, and to launch Jupyter from that environment. The steps below follow the TensorFlow pip instructions for a virtual environment (Linux and macOS shell shown) and the Jupyter project’s classic Notebook instructions.
- Create and activate a virtual environment:
python3 -m venv tf, thensource tf/bin/activate. - Upgrade pip:
pip install --upgrade pip. - Install Jupyter Notebook:
pip3 install jupyter(the Jupyter install page gives this command). - Install TensorFlow for CPU:
pip install tensorflow. For an NVIDIA GPU on Linux, the install page givespip install tensorflow[and-cuda]instead. - Start the notebook server from the same activated environment:
jupyter notebook. - In a new notebook, run the check in the next section.
On Windows, activate the environment with the activation script that Python’s venv creates for your shell. The TensorFlow steps are the same whichever Jupyter interface you launch, as long as it runs in the environment where TensorFlow is installed.
Output and how to read it
TensorFlow’s install page verifies a CPU install with a one-line command that sums a 1000 by 1000 tensor of random numbers. In a notebook cell, the equivalent is:
import tensorflow as tf
print(tf.reduce_sum(tf.random.normal([1000, 1000])))
If a tensor is returned, the installation succeeded. The exact number differs on every run because the input is random. To check whether TensorFlow can see a GPU, the install page uses tf.config.list_physical_devices('GPU'); an empty list means TensorFlow is running on the CPU.
For a reproducible analysis, also print tf.__version__ in the notebook and record it with your Python version in your methods or README. See our entries on computational environment and computational reproducibility for what a reviewer will expect.
Does TensorFlow use my GPU on Windows?
Not on native Windows with current releases. The install page states: “TensorFlow 2.10 was the last TensorFlow release that supported GPU on native-Windows.” For later releases it points to installing TensorFlow in WSL2, or installing tensorflow-cpu and optionally trying the TensorFlow-DirectML-Plugin. macOS installs have no GPU support under the same page’s requirements. GPU setups on Linux also need a matching NVIDIA driver, CUDA and cuDNN; the versions change by release, so take them from the install page rather than from an older tutorial.
Troubleshooting
ModuleNotFoundError: No module named 'tensorflow'in the notebook. The notebook is running in a different Python environment from the one where you ran pip. Stop the server, activate the environment where TensorFlow is installed, and runjupyter notebookfrom there.- TensorFlow will not run on an older machine. The official binaries use AVX instructions, which older CPUs may lack (install page).
- “Status: device kernel image is invalid”. The install page says this means the package does not include PTX for your GPU architecture, and the fix is to build from source.
- Other errors. TensorFlow maintains an install errors page.
Alternatives to TensorFlow
Each row below summarises the project’s own site (checked 2026-10-29).
| Library | What its site says | Source |
|---|---|---|
| PyTorch | Supports distributed training for research and production through the torch.distributed backend; the latest stable release requires Python 3.10 or later. | pytorch.org |
| JAX | “A Python library for accelerator-oriented array computation and program transformation,” with a NumPy-style API; the same code runs on CPU, GPU and TPU. | docs.jax.dev |
FAQ
How do I install TensorFlow in a Jupyter notebook?
Create a virtual environment, install Jupyter and TensorFlow into it with pip, and launch jupyter notebook from that same environment. The numbered steps above give each command.
Should I install TensorFlow with conda?
TensorFlow’s install page says not to: it is officially released to PyPI, so pip is the recommended route.
How do I try TensorFlow without installing anything?
The official tutorials include a “Run in Google Colab” button that opens them as notebooks with no local setup.
How should I cite or document TensorFlow in a paper?
Record the TensorFlow and Python versions you ran and the environment definition you used. For software citation norms, see FAIR4RS and the FORCE11 Software Citation Principles. For how software work fits into research practice, see What Is Software Engineering?
Sources
- TensorFlow overview, checked 2026-10-29.
- Install TensorFlow with pip, checked 2026-10-29.
- Jupyter: installing the classic Notebook, checked 2026-10-29.
- PyTorch and JAX documentation, checked 2026-10-29.








