Jupyter Notebook "Not Trusted" issue [Solved]

avatar
Borislav Hadzhiev

Last updated: Apr 12, 2024
3 min

banner

# Table of Contents

  1. Jupyter Notebook "Not Trusted" issue
  2. Using a command to trust the given notebook
  3. Resolving the issue with the Jupyter Notebook GUI
  4. Using the "Trust Notebook" command to resolve the issue
  5. Creating a notebook in a Docker container with a mounted volume

# Jupyter Notebook "Not Trusted" issue [Solved]

The Jupyter Notebook "Not Trusted" issue is caused because of a security feature that disables the execution of code from untrusted notebooks, without the user's consent.

You can resolve the issue by issuing a command to trust the notebook or by using the graphic user interface to achieve the same.

jupyter notebook not trusted issue

# Using a command to trust the given notebook

One way to resolve the issue is to use a command.

Open your terminal in the same directory as your notebook and issue the jupyter trust command.

shell
jupyter trust my-notebook-name.ipynb

Make sure to replace the my-notebook-name.ipynb placeholder with your actual notebook name.

You can find the notebook name by:

  1. Looking for the .ipynb file in your project's directory.

locate notebook name

  1. Or by looking at the label below the URL as shown in this screenshot.

how to find notebook name

For example, my notebook is named my-notebook.ipynb, so I will issue the following command.

shell
jupyter trust my-notebook.ipynb

issue jupyter trust command

Then you can reopen the notebook by using the jupyter notebook command.

shell
jupyter notebook my-notebook-name.ipynb

Make sure to replace the my-notebook-name.ipynb placeholder with your actual notebook name.

The jupyter trust command tells Jupyter to trust your notebook.

# Resolving the issue with the Jupyter Notebook GUI

You can also resolve the issue by using the Jupyter Notebook GUI:

  1. Open your notebook with the jupyter-notebook or jupyter notebook command.
shell
jupyter notebook
  1. In the top menu, click on File.
  2. Select Trust Notebook.

click file and trust notebook

If you see the "Trusted Notebook" option when you click on File, then your Notebook is already trusted.

You can also resolve the issue by clicking on the "Note Trusted" label.

jupyter notebook not trusted issue

After you click on it, you will be prompted for confirmation.

Click on "Trust".

# Using the "Trust Notebook" command to resolve the issue

You can also use the "Trust Notebook" command to resolve the issue.

If you use Jupyter Lab, click on View in the top menu and then select Activate Command Palette or press Ctrl + Shift + C.

You might also be able to open the Command Palette by pressing Ctrl + Shift + P.

Then type "Trust Notebook" in the command palette and issue the command.

type trust notebook in command palette

# Creating a notebook in a Docker container with a mounted volume

You might also get the error if you create a Notebook in a Docker container with a mounted volume.

The notebook file is owned by the root user, so if you open it in Jupyter on the host machine, it won't be trusted.

In this case, you have to change the ownership of the notebook .ipynb file to the host user.

# Additional Resources

You can learn more about the related topics by checking out the following tutorials:

I wrote a book in which I share everything I know about how to become a better, more efficient programmer.
book cover
You can use the search field on my Home Page to filter through all of my articles.