If you’ve ever typed import tensorflow as tf inside a Jupyter Notebook and got hit with a ModuleNotFoundError, you’re not alone. This is one of the most common frustrations for beginners getting into machine learning, and it almost always comes down to one thing: TensorFlow was installed in a different environment than the one Jupyter is using.
In this guide, I’ll show you exactly how to install TensorFlow and get it working inside Jupyter Notebook, whether you’re using Anaconda Navigator, Anaconda Prompt, or VS Code. I’ll cover the full setup from scratch, including how to register your environment as a Jupyter kernel so everything connects properly.
No guesswork, no copy-paste errors — just a clean, working setup.
How Jupyter Notebook and Environments Work Together
Before we get into steps, let me explain one thing quickly — because understanding this saves you a lot of debugging time.
Jupyter Notebook doesn’t automatically see every Python environment on your machine. It only sees environments that have been registered as a kernel. A kernel is just the Python engine that runs your notebook code.
So when you install TensorFlow in environment A but Jupyter is running on environment B, the import fails — even though TensorFlow is clearly installed somewhere on your computer.
The fix is a two-part process:
- Install TensorFlow inside a specific environment
- Register that environment as a Jupyter kernel so your notebook uses it
Every method below follows this pattern. Once you understand it, everything makes sense.
Method 1: Install TensorFlow on Jupyter Using Anaconda Navigator (GUI)
This is the best method if you prefer clicking over typing commands. Anaconda Navigator gives you a visual interface to manage environments and launch Jupyter.
Step 1: Download and Install Anaconda
If you don’t have Anaconda yet, download it from anaconda.com/download. Choose the version for your operating system (Windows, macOS, or Linux) and follow the instructions.
Once installed, open Anaconda Navigator from your Start Menu (Windows) or Applications folder (macOS).
Step 2: Create a New Environment
In Anaconda Navigator:
- Click Environments in the left sidebar
- Click the Create button at the bottom
- Name your environment — I’ll call mine tf_env
- Select Python 3.11 from the dropdown (recommended for best compatibility)
- Click Create and wait for it to finish. Always create a new environment for TensorFlow. Don’t install it into your base environment — that’s your safety net, and polluting it with ML packages will cause conflicts eventually.
Step 3: Install TensorFlow in that Environment
With tf_env selected in the left panel:
- Change the package filter from Installed to Not installed
- In the search box, type
tensorflow - Check the box next to
tensorflow - Click Apply at the bottom right
- Confirm by clicking Apply again in the pop-up
Anaconda will now resolve and install TensorFlow and all its dependencies. This may take a few minutes.
⚠️ Note: The TensorFlow version in conda-forge may sometimes be slightly behind the latest pip release. If you need the absolute latest version, use Anaconda Prompt with pip install tensorflow (covered in Method 2).
Step 4: Install Jupyter in the Same Environment
While still in tf_env, search for jupyter in the packages list and install it the same way. This ensures Jupyter runs from within your TensorFlow environment.
Step 5: Launch Jupyter Notebook
- Go back to Home in the left sidebar
- At the top, change Applications on from base (root) to tf_env
- Click Launch under Jupyter Notebook
Jupyter will now open in your browser running from inside tf_env — which means TensorFlow is available.
Step 6: Test it
Open a new notebook and run:
import tensorflow as tf
print(tf.__version__)
If you see a version number, you’re done.
Method 2: Install TensorFlow on Jupyter Using Anaconda Prompt (Command Line)
This method gives you more control and installs the latest TensorFlow version using pip. I personally prefer this over the GUI because it’s faster and more predictable.
Step 1: Open Anaconda Prompt
On Windows, search for Anaconda Prompt in the Start Menu and open it. On macOS/Linux, open your regular Terminal — conda is available there once Anaconda is installed.
Step 2: Create a New Conda Environment with Python 3.11
conda create -n tf_env python=3.11
Type y and press Enter when prompted to confirm.
Step 3: Activate the Environment
conda activate tf_env
Your prompt will change to (tf_env), confirming you’re inside the environment.
Step 4: Install TensorFlow using pip
pip install tensorflow
Even inside a conda environment, use pip for TensorFlow. The conda-forge version is often outdated and can cause dependency headaches.
Step 5: Install Jupyter and ipykernel
pip install jupyter ipykernel
ipykernel is the package that allows Jupyter to communicate with Python environments. You must install it here.
Step 6: Register the Environment as a Jupyter Kernel
python -m ipykernel install --user --name=tf_env --display-name "Python (TensorFlow)"
This is the step most guides skip — and it’s the reason so many people end up with TensorFlow installed but Jupyter still can’t find it. This command tells Jupyter: “hey, there’s a Python environment here called tf_env — make it available as a kernel option.”
Step 7: Launch Jupyter Notebook
jupyter notebook
Jupyter will open in your browser.
Step 8: Select the Right Kernel
When you open a new notebook:
- Click Kernel in the top menu
- Select Change Kernel
- Choose Python (TensorFlow) — the name you set in Step 6
Step 9: Test it
import tensorflow as tf
print("TensorFlow version:", tf.__version__)
Method 3: Install TensorFlow on Jupyter Notebook Inside VS Code
VS Code has become one of the most popular ways to work with Jupyter notebooks, especially if you’re doing a mix of scripting and notebook work. Here’s how to get TensorFlow working inside VS Code’s Jupyter environment.
What you need first
- VS Code installed — download from code.visualstudio.com
- Python extension for VS Code (install from the Extensions sidebar, ID:
ms-python.python) - Jupyter extension for VS Code (ID: ms-toolsai.jupyter)
Step 1: Create your TensorFlow environment
If you’ve already followed Method 2 above and created tf_env, skip this step. Otherwise, in your terminal (or Anaconda Prompt):
conda create -n tf_env python=3.11
conda activate tf_env
pip install tensorflow ipykernel
python -m ipykernel install --user --name=tf_env --display-name "Python (TensorFlow)"
Step 2: Open VS Code and select the environment
- Open VS Code
- Press Ctrl+Shift+P (Windows/Linux) or Cmd+Shift+P (macOS) to open the Command Palette
- Type Python: Select Interpreter
- Choose your tf_env conda environment from the list
You’ll see the selected interpreter in the bottom-left status bar of VS Code.
Step 3: Create or open a Jupyter Notebook
- Press Ctrl+Shift+P and type Create: New Jupyter Notebook
- A .ipynb file will open inside VS Code
Step 4: Select the kernel in the notebook
In the top-right of the VS Code notebook interface, you’ll see a kernel selector (it might say “Select Kernel” or show a Python version). Click it and choose Python (TensorFlow) — the kernel you registered earlier.