61

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'

NelsonGon
  • 13,015
  • 7
  • 27
  • 57
CodeNinja101
  • 1,091
  • 4
  • 11
  • 19

31 Answers31

78

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.

Bex T.
  • 1,062
  • 1
  • 12
  • 28
Ganesh Pandey
  • 5,216
  • 1
  • 33
  • 39
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.

Kenneth Eggering
  • 230
  • 3
  • 14
Zompa
  • 448
  • 4
  • 8
  • 1
    After trying everything on chmod and chown finally this way it worked. – Neeraj Sharma Jun 13 '19 at 08:47
  • Following a cue from this, I changed the permissions on the folder containing the ipynb files and it worked. – emeralddove Apr 27 '20 at 04:00
  • 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 project – lxx Apr 17 '22 at 00:11
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
Shweta Chandel
  • 887
  • 7
  • 17
  • 13
    As above - please do not use `chmod 777`! This is a real security issue. – cirrusio Aug 17 '20 at 05:53
  • 5
    NOOO! chmod 777 on `.local` folder is a horrible idea. You are letting everyone modify and execute your binaries! – MuhsinFatih Dec 02 '20 at 20:05
  • 5
    (to elaborate): your `.local` folder should always have permissions `700` which basically allows you to do everything and you alone – MuhsinFatih Dec 02 '20 at 20:18
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?

Krystian
  • 71
  • 1
  • 3
  • 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! – Olexiy Jun 08 '21 at 11:29
  • This is a problem now that Ubuntu 22.04 installs firefox via 'snap'... – Guillem May 04 '22 at 10:02
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!

Bryan Blackford
  • 186
  • 2
  • 6
  • 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. – Michael_Zhang May 05 '19 at 23:11
3
  1. Open Anaconda prompt
  2. Go to C:\Users\your_name
  3. Write jupyter trust untitled.ipynb
  4. Then, write jupyter notebook
Paul Roub
  • 36,322
  • 27
  • 84
  • 93
Shubham Agrawal
  • 1,252
  • 12
  • 29
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

ShaneCalder
  • 316
  • 2
  • 5
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.

JimH23
  • 11
  • 2
1

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

sudo chown -R user:usergroup /home/user/.local/share/jupyter/*
Hrvoje
  • 13,566
  • 7
  • 90
  • 104
1

Seems like the problem is in the last release, so

pip install notebook==5.6.0

must solve the problem!

Zarrie
  • 325
  • 2
  • 16
1

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

emeralddove
  • 520
  • 1
  • 5
  • 11
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

Idan Hazan
  • 116
  • 9
0

This worked for me:

-> uninstalled Jupyter
-> install jupyter in Python36 folder
-> open Jupyter from command prompt instead of git bash.
LarsTech
  • 80,625
  • 14
  • 153
  • 225
Nimita
  • 1
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.

Abdullah Akhtar
  • 529
  • 5
  • 14
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

Rich Hildebrand
  • 1,607
  • 17
  • 15
0

Executing the script below worked for me.

sudo chown $USER /home/$USER/.jupyter
MT_Shikomba
  • 129
  • 1
  • 6
0

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

.~SomeAmazingNotebook.ipynb

renamed it:

SomeAmazingNotebook.ipynb

and could open it.

cs0815
  • 16,751
  • 45
  • 136
  • 299
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.

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.

Subra M
  • 581
  • 1
  • 8
  • 16
0

I tried opening from the Python folder and it helped.

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

ejuhjav
  • 2,660
  • 2
  • 21
  • 32
Julia
  • 1
0

Try creating the notebook in the /home/ubuntu folder

João Raffs
  • 177
  • 1
  • 9
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

32cupo
  • 850
  • 5
  • 18
  • 36
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! :)

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.

Dharman
  • 30,962
  • 25
  • 85
  • 135
ASHUTOSH
  • 1
  • 1
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.

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 
karel
  • 5,489
  • 46
  • 45
  • 50
-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

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

-1

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

ZIZI_noob
  • 13
  • 5
  • 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](/help/how-to-answer). – Community Nov 14 '21 at 14:55
-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.

Beanwah
  • 1,290
  • 2
  • 17
  • 28
-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.)

Behzad Sezari
  • 728
  • 8
  • 11
  • 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) – Behzad Sezari Apr 24 '20 at 15:00
  • 2
    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. – cirrusio Aug 17 '20 at 05:41