Cannot open new Jupyter Notebook [Permission Denied]

Question:

I have installed Jupyter Notebook on ubuntu 16.04 using pip3. I can execute jupyter notebook command. It opens and shows a list of current path directories.

But I cannot create a new notebook(Python3). It says

Unexpected error while saving file: Deep Learning/NN/Untitled.ipynb [Errno 13] Permission denied: ‘/home/ubuntu/.local/share/jupyter/notebook_secret’

Asked By: CodeNinja101

||

Answers:

change the ownership of the ~/.local/share/jupyter directory from root to user.

sudo chown -R user:user ~/.local/share/jupyter 

see here: https://github.com/ipython/ipython/issues/8997

The first user before the colon is your username, the second user after the colon is your group. If you get chown: [user]: illegal group name, find your group with groups, or specify no group with sudo chown user: ~/.local/share/jupyter.

EDIT: Added -R option in comments to the answer. You have to change ownership of all files inside this directory (or inside ~/.jupyter/, wherever it gives you PermissionError) to your user to make it work.

If this fails, change the ownership of the directory you want to create the notebook in. For mydir:

sudo chown -R user:user mydir/*

Note that I replaced user:user with bexgboost:root where bexgboost is my UNIX username.

Answered By: Ganesh Pandey

It might be a trust issue.
Command-line
jupyter trust /path/to/notebook.ipynb
here is the documentation link :
http://jupyter-notebook.readthedocs.io/en/latest/security.html#security-in-notebook-documents

Answered By: ShaneCalder

I had the very same issue running Jupyter. After chasing my tail on permissions, I found that everything cleared up after I changed ownership on the directory where I was trying to run/store my notebooks. Ex.: I was running my files out of my ~/bash dir. That was root:root; when I changed it to jim:jim….no more errors.

Answered By: JimH23
  1. Open Anaconda prompt
  2. Go to C:Usersyour_name
  3. Write jupyter trust untitled.ipynb
  4. Then, write jupyter notebook
Answered By: Shubham Agrawal

Tried everything that was suggested but finally this helped me:

sudo jupyter notebook --allow-root

In my case, it didn’t start the browser by itself. So just copy the link from terminal and open it by yourself.

Update:
Change folder(.local) permissions by this command:

sudo chmod -R 777 .local
Answered By: Shweta Chandel

This worked for me:

-> uninstalled Jupyter
-> install jupyter in Python36 folder
-> open Jupyter from command prompt instead of git bash.
Answered By: Nimita

I had to run chown recursively for all subfolders With /* . Than it worked:

sudo chown -R user:usergroup /home/user/.local/share/jupyter/*
Answered By: Hrvoje

On a Windows machine run the python command prompt as administrator. That should resolved the permissions issue when creating a new python 3 notebook.

Answered By: Beanwah

In my opinion, it is a good practice to run Jupyter in a dedicated workbook folder.

$ mkdir jupyter_folder
$ jupyter-notebook --notebook-dir jupyter_folder

where ‘jupyter_folder’ is a folder in my home.

This method works without any permission issues.

Answered By: Zompa

The top answer here didn’t quite fix the problem, although it’s probably a necessary step:

sudo chown -R user:user ~/.local/share/jupyter 

(user should be whoever is the logged in user running the notebook server)
This changes the folder owner to the user running the server, giving it full access.

After doing this, the error message said it didn’t have permission to create the checkpoint file in ~/.ipynb_checkpoints/ so I also changed ownership of that folder (which was previously root)

sudo chown -R user:user ~/.ipynb_checkpoints/

And then I was able to create and save a notebook!

Answered By: Bryan Blackford

Seems like the problem is in the last release, so

pip install notebook==5.6.0

must solve the problem!

Answered By: Zarrie

You don’t have to install or uninstall anything.
if you are using python 2 use pip to install and upgrade. But if you want to use python3 then follow the steps below:

sudo apt-get install python3-pip python3-dev

then in terminal use this

pip3 install -U jupyter

final step is to launch jupyter notebook so,in terminal just type

jupyter notebook

all the issues or problems of premissions etc will be resolved.

Answered By: Abdullah Akhtar

I had the same issue and it turned out my windows password had changed since I shared my drive with docker.

The fix was to rest my credentials in docker settings -> shared drives -> reset credentials and then reshare my drive.

docker reset credentials

Answered By: Rich Hildebrand

Based on my experience on Ubuntu 18.04:

1. Check Jupyter installation

first of all make sure that you have installed and/or upgraded Jupyter-notebook (also for virtual-environment):

pip install --upgrade jupyter 

2. Change the Access Permissions (Use with Caution!)

then try to change the access permission for you

sudo chmod -R 777 ~/.local

where 777 is a three-digit representation of the access permission. In sense that each of the digits representing short format of the binary one (e.g. 7 for 111).
So, 777 means that we set permission access to read, write and execute to 1 for all users (Owner, Group or Other)

Example.1

777 : 111 111 111

or

777 : rwx-rwx-rwx

Example.2

755 : 111 101 101

  • Owner: rwx=4+2+1=7
  • Group: r-x=4+0+1=5
  • Other: r-x=4+0+1=5

(More about chmod : File Permissions and attributes)

3. Run jupyter

afterwards run your jupyter notebook:

jupyter-notebook

Note: (These steps also solve your Visual-Studio code (VS-Code) problems regarding permissions while using ipython and jupyter for python-interactive-console.)

Answered By: Behzad Sezari

Executing the script below worked for me.

sudo chown $USER /home/$USER/.jupyter
Answered By: MT_Shikomba
  • List item
  • List item

this problem of not able to open jupyter notebook is like Corona virus.I came across several complaints-including my own.I use windows 10.

Atlast after struggling for 3 days i came across this wonderful foolproof solution:-

1.The jupyter folder is created at path:-
C:Usersdeviv_000AppDataRoamingjupyter
your name will replace->deviv_000

2.Go to cmd and write :
cd C:Usersdeviv_000AppDataRoamingjupyter
this will take cmd to that folder.

3.Now create manually a file as untitled.ipynb in jupyter folder.

4.Come back to cmd and write:
jupyter trust untitled.ipynb

5.After cmd performs this operation now write:-
jupyter notebook

SUCCESS!!- your notebook will appear in the next tab.I used chrome.

Regards

Answered By: user1744515

On Ubuntu, ‘permission denied’ may appear when browser is installed as a ‘snap’. I had this problem. I edited config file to open a regular browser and it worked.

How to change the default browser used by the ipython/jupyter notebook in Linux?

Answered By: Krystian

Try running "~/anaconda3/bin/jupyter notebook" instead of "jupyter notebook".
This resolved the problem for me. No more getting ‘permission denied’ error.

Answered By: emeralddove

I encountered same problem when I installed latest version of anaconda navigator 64 bit on windows 10.

I got to know that INSTALLING 32 BIT VERSION ON WINDOWS 10 will solve the issue.
It worked for me. Jupyter is running smoothly now.

Answered By: Shweta Tomar

In windows, I copied, what I think is a snapshot:

.~SomeAmazingNotebook.ipynb

renamed it:

SomeAmazingNotebook.ipynb

and could open it.

Answered By: cs0815

None of the above worked for me but the below did:

sudo chown -R user: /Library/Frameworks/Python.framework/Versions/3.9/share/jupyter/

Where user is your username.

Answered By: Jesse Murrell

I was launching it from the root dir "/" for which I was lacking the write permission and hence file creation failed as below

Unexpected error while saving file: Untitled.ipynb [Errno 30] Read-only file system: '/Untitled.ipynb'

Once after I re-launched it from other dir , I was able to proceed.

Answered By: Subra M

I tried opening from the Python folder and it helped.

C:UsersJulia>appdatalocalprogramspythonpython39python.exe -m jupyter notebook

Answered By: Julia

Try creating the notebook in the /home/ubuntu folder

Answered By: João Raffs

I closed notebook page and:

  1. I killed notebook kernel, since I was using DockerSpawner I needed to delete notebook’s container
  2. I deleted user jupyter directory by running rm -rf ~/.local/share/jupyter

When I tried to create new notebook next time, it started working

Answered By: 32cupo
  1. Create a configuration file: jupyter notebook --generate-config.
  2. Edit a configuration file: sudo gedit /home/<USERNAME>/.jupyter/jupyter_notebook_config.py (You can use vim, nano or anything else instead of gedit)
  3. Uncomment a line and change the default value:

BEFORE: # c.NotebookApp.use_redirect_file = True

AFTER: c.NotebookApp.use_redirect_file = False

Answered By: Idan Hazan

An easy way is to run your terminal in the mode of "Administrator"

Answered By: ZIZI_noob

A complicated problem this one.. but finally I found a solution.

You need to generate a config file:

jupyter notebook –generate-config

Its created in the .jupyter directory.
If its hidden, do a CTRL+H to unhide the files.
Look for c.NotebookApp.use_redirect_file and make it like this:

c.NotebookApp.use_redirect_file = False.

Make sure to remove the # before the line. Otherwise it won’t work.
Done! 🙂

Answered By: Atharv Nuthi

I solved the problem by changing the owner of my current folder. Whenever we type jupyter notebook on terminal, it always opens up in the current path (which we are pointing to via terminal), so we just have to change the owner to current user and then if you click on "new notebook", it will create one for you without giving permission denied error.

Answered By: ASHUTOSH

My os is Ubuntu 22.04 LTS. When I use Chrome, which was downloaded from official site. I solved this problem. Perhaps this is because Firefox and chromium on Ubuntu are base on Snap.

Answered By: 杨树浩

I tried the accepted answer in Ubuntu 22.04 answer, but it didn’t work for me which I discovered was because Firefox is packaged as a snap package in Ubuntu 22.04. I circumvented this obstacle by installing Web (Web browser for GNOME) with this command:

sudo apt install epiphany 

Create jupyter_notebook_config.py by:

jupyter notebook --generate-config # type y for yes at the prompt

Then open ~/.jupyter/jupyter_notebook_config.py for editing in a text editor and change:

# c.NotebookApp.browser = ''

to:

c.NotebookApp.browser = '/usr/bin/epiphany'

Don’t forget to delete the # so it’s not a comment anymore. Inspiration for these last 2-3 steps goes to https://stackoverflow.com/a/35578527/. You can use a different web browser if you don’t like Web as long as it’s not a snap package and you change the path from /usr/bin/epiphany to the path to your web browser which you can find by running a command of the form which my-web-browser.

It still won’t work though, so you have to do one more step. It’s the same as in the accepted answer to this question. Change the ownership of the ~/.local/share/jupyter directory from root to user. Instead of user in the below command replace it with your own username that you login with.

sudo chown -R user:user ~/.local/share/jupyter 
Answered By: karel
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.