How to Download & Install Tensorflow in Jupyter Notebook
โก Smart Summary
TensorFlow installs cleanly inside an isolated Anaconda environment, which keeps Python, Jupyter and the framework resolving to one path and prevents version clashes with every other data project already living on the same machine.
Installing TensorFlow with Anaconda on Windows or macOS takes one conda environment and a few commands. You will also learn how to import TensorFlow inside Jupyter Notebook, the browser-based notebook viewer.
TensorFlow Versions
TensorFlow supports computations across multiple CPUs and GPUs. It means that the computations can be distributed across devices to improve the speed of the training. With parallelization, you don’t need to wait for weeks to obtain the results of training algorithms.
For Windows users, TensorFlow provides two build variants:
- TensorFlow with CPU support only: If your machine has no NVIDIA GPU, install this build.
- TensorFlow with GPU support: Faster for training, but worth the setup only when you need real computational capacity.
During this tutorial, the basic version of TensorFlow is sufficient. The table below compares the two builds:
| Criterion | CPU build | GPU build |
|---|---|---|
| Package | tensorflow (CPU wheel) | tensorflow with CUDA runtime |
| Hardware | Any x86 or ARM processor | NVIDIA card with supported CUDA |
| Best for | Tutorials, small models | Large training runs |
| Setup effort | One command | Driver, CUDA and cuDNN matching |
Version note: TensorFlow 2.10 was the last release with native Windows GPU support. From 2.11 onward, Windows users run the GPU build inside WSL2 or install the CPU package. Apple Silicon Macs add tensorflow-metal for acceleration.
Note: TensorFlow does not provide CUDA GPU support on macOS.
Here is how to proceed
macOS users:
- Install Anaconda
- Create a .yml file to install TensorFlow and dependencies
- Launch Jupyter Notebook
Windows users:
- Install Anaconda
- Create a .yml file to install dependencies
- Use pip to add TensorFlow
- Launch Jupyter Notebook
To run TensorFlow with Jupyter, create a dedicated environment inside Anaconda holding IPython, Jupyter and TensorFlow. Add one essential data science library as well: pandas, which manipulates data frames.
Install Anaconda
Download Anaconda version 4.3.1 (for Python 3.6) for the appropriate system.
Those versions are legacy: current TensorFlow 2.x pairs with Python 3.9 to 3.12. Since 2024 the Anaconda default channel also requires a paid licence for organisations above 200 people, so Miniconda or Miniforge with conda-forge is the free route.
Anaconda manages the libraries required for Python or R, then installs them per environment.
Create .yml file to install TensorFlow and dependencies
It includes
- Locate the path of Anaconda
- Set the working directory to Anaconda
- Create the yml file (For MacOS user, TensorFlow is installed here)
- Edit the yml file
- Compile the yml file
- Activate Anaconda
- Install TensorFlow (Windows user only)
Step 1) Locate Anaconda,
The first step you need to do is to locate the path of Anaconda.
You will create a conda environment holding the libraries used throughout the TensorFlow tutorials.
Windows
If you are a Windows user, you can use Anaconda Prompt and type:
C:\>where anaconda
We are interested to know the name of the folder where Anaconda is installed because we want to create our new environment inside this path. In the picture above, Anaconda sits in the Admin folder; yours will carry your own user name.
Next, you will move the working directory from c:\ to Anaconda3.
MacOS
For macOS users, open the Terminal and type:
which anaconda
You now create a folder inside Anaconda that will contain IPython, Jupyter and TensorFlow. The quickest way to declare those libraries is a yml file.
Step 2) Set working directory
Specify the working directory where the yml file will be created; as noted above, it sits inside Anaconda.
For macOS users:
The Terminal defaults to Users/USERNAME. In the figure below the anaconda3 path and the working directory match; macOS shows the current folder before the $. Every library is installed there.
If the path in your text editor does not match, run cd PATH in the Terminal, quoting the path when it contains spaces.
Open your Terminal, and type:
cd anaconda3
For Windows users, check the folder that precedes Anaconda3:
cd C:\Users\Admin\Anaconda3
or the path “where anaconda” command gives you
Step 3) Create the yml file
You can create the yml file inside the new working directory.
The file will install the dependencies you need to run TensorFlow. Copy and paste this code into the Terminal.
For MacOS user:
touch hello-tf.yml
A new file named hello-tf.yml should appear inside anaconda3
For Windows user:
echo.>hello-tf.yml
A new file named hello-tf.yml should appear
Step 4) Edit the yml file
You are ready to edit the yml file.
For MacOS user:
You can paste the following code in the Terminal to edit the file. MacOS user can use vim to edit the yml file.
vi hello-tf.yml
So far, your Terminal looks like this
You enter an edit mode. Inside this mode, you can, after pressing esc:
- Press i to start editing
- Press esc, then type :w to save
- Press esc, then type :q! to quit without saving
Write the following code in the edit mode and press esc followed by :w
Note: The file is case and indentation sensitive. Two spaces are required for each indent level.
For MacOS
name: hello-tf dependencies: - python=3.6 - jupyter - ipython - pandas - pip: - https://storage.googleapis.com/tensorflow/MacOS/cpu/tensorflow-1.5.0-py3-none-any.whl
Code Explanation
- name: hello-tf: Name of the yml file
- dependencies:
- python=3.6
- jupyter
- ipython
- pandas: Install Python 3.6, Jupyter, IPython and pandas.
- pip: Install a Python library
- The wheel URL: install TensorFlow directly from the Google storage API.
Press esc followed by :q! to leave edit mode.
For Windows User:
Windows has no vim, so Notepad is enough for this step.
notepad hello-tf.yml
Enter following into the file
name: hello-tf dependencies: - python=3.6 - jupyter - ipython - pandas
Code Explanation
- name: hello-tf: Name of the yml file
- dependencies:
- python=3.6
- jupyter
- ipython
- pandas: Install Python 3.6, Jupyter, IPython and pandas.
It will open the notepad, you can edit the file from here.
Note: Windows users install TensorFlow in the next step; here you only prepare the conda environment.
Step 5) Compile the yml file
Compile the .yml file with the following command:
conda env create -f hello-tf.yml
Note: For Windows users, the new environment is created inside the current user directory.
It takes time and roughly 1.1 GB of disk space.
In Windows
Step 6) Activate conda environment
You now have two conda environments.
An isolated environment is recommended practice, because each machine learning project needs a different library set, and you can delete it when the project ends.
conda env list
The asterisk marks the active environment. Switch to hello-tf to activate it. Modern conda uses conda activate on every platform; source activate is deprecated.
For MacOS user:
source activate hello-tf
For Windows user:
activate hello-tf
Confirm every dependency resolves inside the same environment, so Python, Jupyter and TensorFlow share one prefix. If the three paths differ, rebuild the environment.
For MacOS user:
which python which jupyter which ipython
Optional: Check for an update.
pip install --upgrade tensorflow
Step 7) Install TensorFlow For Windows user
For Windows users:
where python where jupyter where ipython
Two Python environments now exist: the base one and hello-tf. Only hello-tf carries TensorFlow. In the picture, python, jupyter and ipython all resolve to the same environment, so TensorFlow is usable from a Jupyter Notebook.
Windows users install TensorFlow with pip:
pip install tensorflow
How to Import TensorFlow in Jupyter Notebook
This part is identical on both operating systems. Remember that the environment must be activated every time before you open TensorFlow.
You will proceed as follow:
- Activate hello-tf conda environment
- Open Jupyter
- Import TensorFlow
- Delete Notebook
- Close Jupyter
Step 1) Activate conda
For MacOS user:
source activate hello-tf
For Windows user:
conda activate hello-tf
Step 2) Open Jupyter
After that, you can open Jupyter from the Terminal
jupyter notebook
The browser should open automatically; otherwise copy the URL printed by the Terminal, which starts with http://localhost:8888.
The dashboard lists every file in the working directory. Click New and Python 3 to create a notebook.
Note: The new notebook is automatically saved inside the working directory.
Step 3) Import TensorFlow
Inside the notebook, you can import TensorFlow in Jupyter Notebook with the tf alias. Click to run. A new cell is created below.
import tensorflow as tf
Let’s write your first code with TensorFlow.
hello = tf.constant('Hello, Guru99!') hello
A new tensor is created. Congratulations, TensorFlow now runs with Jupyter on your machine.
Step 4) Delete file
Delete the file named Untitled.ipynb from the Jupyter dashboard.
Step 5) Close Jupyter
Jupyter can be closed from the notebook itself or from the terminal (Anaconda Prompt on Windows).
From Jupyter
In the main panel of Jupyter Notebook, simply click on Logout
You are redirected to the log out page.
From the terminal
Select the terminal or Anaconda Prompt and press Ctrl+C twice.
The first Ctrl+C asks you to confirm the shutdown; the second confirms it.
You have successfully logged out.
Jupyter with the main conda environment
To launch TensorFlow with Jupyter in a future session, activate the environment first:
source activate hello-tf
Without that step, Jupyter starts in the base environment and the import fails.




























