Cannot open new Jupyter Notebook [Permission Denied]
Asked Answered
M

31

66

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'

Maki answered 18/9, 2017 at 6:30 Comment(0)
I
83

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.

Intersection answered 18/9, 2017 at 6:34 Comment(5)
sudo chown -R user:user ~/.local/share/jupyterSylvan
How do we do this in windows?Universalism
I had to logout and login on ubuntu to make it work.Careycarfare
There is no such directory on my system. I use snap to install jupyter.Warn
On CentOS7, I had this complaining about a /run/user/0/jupyter. Changed owner for /run/user/0/Pepe
B
18

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.

Baghdad answered 14/11, 2018 at 0:45 Comment(3)
After trying everything on chmod and chown finally this way it worked.Rouge
Following a cue from this, I changed the permissions on the folder containing the ipynb files and it worked.Hampstead
This works perfectly in ubuntu 22, with everything as snaps. Set an alias in your ~.zshr or .bashrc or have an alias for each major projectIlltimed
N
12

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
Neume answered 9/7, 2018 at 5:46 Comment(3)
As above - please do not use chmod 777! This is a real security issue.Monometallic
NOOO! chmod 777 on .local folder is a horrible idea. You are letting everyone modify and execute your binaries!Rebeca
(to elaborate): your .local folder should always have permissions 700 which basically allows you to do everything and you aloneRebeca
E
7

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?

Exponential answered 16/4, 2020 at 13:41 Comment(2)
Chromium was "converted" to snap while upgrading to Ubuntu 20.04. That was exactly the reason of "permission" issue. I set the default browser to /usr/bin/firefox as explained in the linked answer and ... now it works fine!Serge
This is a problem now that Ubuntu 22.04 installs firefox via 'snap'...Hoofer
W
5

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!

Willock answered 26/12, 2018 at 22:37 Comment(1)
For those whose error message is Permission denied: .ipynb_checkpoints, this is the solution. Basically change the ownership to current user, who will be able to create and save checkpoints.Elephant
T
3
  1. Open Anaconda prompt
  2. Go to C:\Users\your_name
  3. Write jupyter trust untitled.ipynb
  4. Then, write jupyter notebook
Trunkfish answered 20/6, 2018 at 12:57 Comment(1)
giver same permission denieVogele
G
2

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

Granger answered 18/9, 2017 at 6:36 Comment(0)
R
1

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.

Ridgepole answered 20/10, 2017 at 22:46 Comment(0)
H
1

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

sudo chown -R user:usergroup /home/user/.local/share/jupyter/*
Hodman answered 26/9, 2018 at 9:13 Comment(1)
You don't need /* - the -R switch should be sufficient.Monometallic
C
1

Seems like the problem is in the last release, so

pip install notebook==5.6.0

must solve the problem!

Carducci answered 28/4, 2019 at 16:45 Comment(0)
H
1

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

Hampstead answered 15/7, 2020 at 5:51 Comment(0)
S
1
  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

Suppositious answered 31/10, 2021 at 9:6 Comment(0)
S
0

This worked for me:

-> uninstalled Jupyter
-> install jupyter in Python36 folder
-> open Jupyter from command prompt instead of git bash.
Sherborn answered 21/8, 2018 at 18:39 Comment(0)
E
0

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.

Eberhard answered 17/7, 2019 at 5:46 Comment(0)
O
0

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

Outgrow answered 18/7, 2019 at 14:21 Comment(0)
L
0

Executing the script below worked for me.

sudo chown $USER /home/$USER/.jupyter
Liana answered 23/12, 2019 at 8:18 Comment(0)
P
0

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

.~SomeAmazingNotebook.ipynb

renamed it:

SomeAmazingNotebook.ipynb

and could open it.

Poree answered 22/12, 2020 at 12:45 Comment(0)
R
0

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.

Resentful answered 11/1, 2021 at 15:33 Comment(0)
A
0

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.

Abettor answered 28/4, 2021 at 23:28 Comment(0)
S
0

I tried opening from the Python folder and it helped.

C:\Users\Julia>appdata\local\programs\python\python39\python.exe -m jupyter notebook

Sodomy answered 2/7, 2021 at 22:50 Comment(0)
D
0

Try creating the notebook in the /home/ubuntu folder

Ducan answered 14/9, 2021 at 14:58 Comment(0)
I
0

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

Immobile answered 11/10, 2021 at 9:51 Comment(0)
F
0

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! :)

Franklynfrankness answered 16/12, 2021 at 16:26 Comment(0)
M
0

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.

Madian answered 23/1, 2022 at 19:40 Comment(0)
S
0

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.

Shire answered 9/5, 2022 at 6:31 Comment(0)
M
0

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 
Marijo answered 29/6, 2022 at 17:45 Comment(0)
J
-1
  • 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:\Users\deviv_000\AppData\Roaming\jupyter your name will replace->deviv_000

2.Go to cmd and write : cd C:\Users\deviv_000\AppData\Roaming\jupyter 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

Jokester answered 8/2, 2020 at 9:22 Comment(1)
This concerns Ubuntu, not Windows so this answer is not relevant.Monometallic
D
-1

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.

Dorothadorothea answered 16/9, 2020 at 8:12 Comment(0)
R
-1

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

Rein answered 14/11, 2021 at 8:54 Comment(1)
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Radferd
D
-2

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

Doubs answered 2/11, 2018 at 12:25 Comment(0)
M
-2

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.)

Mcmasters answered 23/7, 2019 at 19:49 Comment(2)
I totally explained what chmod 777 does. It is up to you to give those permissions or not. (refer to provided references for more security options)Mcmasters
I am going to point out that you are changing the permissions on an entire directory that generally contains much more than just the jupyter files you are interested in. This creates all kinds of security issues. Using chmod 777 is just bad practice in general. You need to root cause the error rather than just changing the directory to be permissive like this.Monometallic

© 2022 - 2024 — McMap. All rights reserved.