Notebook: Unable to create jupyter notebook

Created on 11 Oct 2017  Â·  25Comments  Â·  Source: jupyter/notebook

Hi,

I am getting an error while creating an jupyter notebook on ubuntu.

I am getting follwing error.

OSError: [Errno 13] Permission denied: '/home/ubuntu/.local/share/jupyter'
[W 11:37:05.336 NotebookApp] Unexpected error while saving file: Untitled.ipynb [Errno 13] Permission denied: '/home/ubuntu/.local/share/jupyter'
[E 11:37:05.336 NotebookApp] {
"Content-Length": "19",
"Accept-Language": "en-US,en;q=0.5",
"Accept-Encoding": "gzip, deflate, br",
"X-Xsrftoken": "2|327d203c|041fe57cf5370b97a158a8b03bbaad7e|1506427435",
"X-Requested-With": "XMLHttpRequest",
"Host": "52.25.207.37:8888",
"Accept": "application/json, text/javascript, /; q=0.01",
"User-Agent": "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:56.0) Gecko/20100101 Firefox/56.0",
"Connection": "keep-alive",
"Referer": "https://52.25.207.37:8888/tree",
"Cookie": "_xsrf=2|327d203c|041fe57cf5370b97a158a8b03bbaad7e|1506427435; username-52-25-207-37-8888=\"2|1:0|10:1507721819|26:username-52-25-207-37-8888|44:MjNiYzQwYmVlMjgxNDExMzk3MWRkZGNjNDViNmJjNDA=|1e275afbc625c06f90502a11b660f126fe6487d00eff5d20499d3e6f44de0672\"",
"Content-Type": "application/json"
}
[E 11:37:05.336 NotebookApp] 500 POST /api/contents (115.114.191.92) 6.26ms referer=https://52.25.207.37:8888/tree

There is no folder '/home/ubuntu/.local/share/jupyter' created while installing anaoconda.

Most helpful comment

Then it looks like rm /home/ubuntu/.local/share/jupyter && mkdir /home/ubuntu/.local/share/jupyter should do what we need.

All 25 comments

That's weird. Does that folder exist at all. Is there a traceback before the error showing what code caused it?

Please find the below traceback.

[I 12:12:13.472 NotebookApp] Creating new notebook in
[E 12:12:13.475 NotebookApp] Error while saving file: Untitled.ipynb [Errno 13] Permission denied: '/home/ubuntu/.local/share/jupyter'
Traceback (most recent call last):
File "/home/ubuntu/anaconda2/lib/python2.7/site-packages/notebook/services/contents/filemanager.py", line 421, in save
self.check_and_sign(nb, path)
File "/home/ubuntu/anaconda2/lib/python2.7/site-packages/notebook/services/contents/manager.py", line 439, in check_and_sign
if self.notary.check_cells(nb):
File "/home/ubuntu/anaconda2/lib/python2.7/site-packages/traitlets/traitlets.py", line 556, in __get__
return self.get(obj, cls)
File "/home/ubuntu/anaconda2/lib/python2.7/site-packages/traitlets/traitlets.py", line 535, in get
value = self._validate(obj, dynamic_default())
File "/home/ubuntu/anaconda2/lib/python2.7/site-packages/notebook/services/contents/manager.py", line 58, in _notary_default
return sign.NotebookNotary(parent=self)
File "/home/ubuntu/anaconda2/lib/python2.7/site-packages/nbformat/sign.py", line 392, in __init__
self.store = self.store_factory()
File "/home/ubuntu/anaconda2/lib/python2.7/site-packages/nbformat/sign.py", line 340, in factory
return SQLiteSignatureStore(self.db_file)
File "/home/ubuntu/anaconda2/lib/python2.7/site-packages/traitlets/traitlets.py", line 556, in __get__
return self.get(obj, cls)
File "/home/ubuntu/anaconda2/lib/python2.7/site-packages/traitlets/traitlets.py", line 535, in get
value = self._validate(obj, dynamic_default())
File "/home/ubuntu/anaconda2/lib/python2.7/site-packages/nbformat/sign.py", line 351, in _db_file_default
if not self.data_dir:
File "/home/ubuntu/anaconda2/lib/python2.7/site-packages/traitlets/traitlets.py", line 556, in __get__
return self.get(obj, cls)
File "/home/ubuntu/anaconda2/lib/python2.7/site-packages/traitlets/traitlets.py", line 535, in get
value = self._validate(obj, dynamic_default())
File "/home/ubuntu/anaconda2/lib/python2.7/site-packages/nbformat/sign.py", line 328, in _data_dir_default
return app.data_dir
File "/home/ubuntu/anaconda2/lib/python2.7/site-packages/traitlets/traitlets.py", line 556, in __get__
return self.get(obj, cls)
File "/home/ubuntu/anaconda2/lib/python2.7/site-packages/traitlets/traitlets.py", line 535, in get
value = self._validate(obj, dynamic_default())
File "/home/ubuntu/anaconda2/lib/python2.7/site-packages/jupyter_core/application.py", line 93, in _data_dir_default
ensure_dir_exists(d, mode=0o700)
File "/home/ubuntu/anaconda2/lib/python2.7/site-packages/ipython_genutils/path.py", line 167, in ensure_dir_exists
os.makedirs(path, mode=mode)
File "/home/ubuntu/anaconda2/lib/python2.7/os.py", line 157, in makedirs
mkdir(name, mode)
OSError: [Errno 13] Permission denied: '/home/ubuntu/.local/share/jupyter'
[W 12:12:13.477 NotebookApp] Unexpected error while saving file: Untitled.ipynb [Errno 13] Permission denied: '/home/ubuntu/.local/share/jupyter'
[E 12:12:13.478 NotebookApp] {
"Content-Length": "19",
"Accept-Language": "en-US,en;q=0.5",
"Accept-Encoding": "gzip, deflate, br",
"X-Xsrftoken": "2|327d203c|041fe57cf5370b97a158a8b03bbaad7e|1506427435",
"X-Requested-With": "XMLHttpRequest",
"Host": "52.25.207.37:8888",
"Accept": "application/json, text/javascript, /; q=0.01",
"User-Agent": "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:56.0) Gecko/20100101 Firefox/56.0",
"Connection": "keep-alive",
"Referer": "https://52.25.207.37:8888/tree",
"Cookie": "_xsrf=2|327d203c|041fe57cf5370b97a158a8b03bbaad7e|1506427435; username-52-25-207-37-8888=\"2|1:0|10:1507723927|26:username-52-25-207-37-8888|44:Y2ZlZDQ2NzgwZjQ1NGEyYjk1MjQxMTY5YmZjMTg2Mzg=|9347d6a8265f0d6ad3911623592096197f434b559706c355433d3ae21e45b595\"",
"Content-Type": "application/json"
}
[E 12:12:13.478 NotebookApp] 500 POST /api/contents (115.114.191.92) 6.16ms referer=https://52.25.207.37:8888/tree

It looks like it is trying to create the default data dir in $HOME/.local/share/jupyter, selected here.

So what is the solution? Shall I have to manually change the line in jupyter core?

My jupyter is installed in '/home/ubuntu/anaconda2/bin/jupyter'.

I think that can only mean that one of the parent directories, e.g. ~/.local/share exists but is not writable. Check the permissions.

I changed the permission of it by chown 777 ~/.local/share. But,still the problem is there.

The main problem is that there is no folder named /home/ubuntu/.local/share/jupyter.

And the jupyter is installed at /home/ubuntu/anaconda2/bin/jupyter.

Does it work if you create the full ~/.local/share/jupyter?

Some more details of paths set for jupyter.

jupyter --paths
config:
    /home/ubuntu/anaconda2/bin/
    /home/ubuntu/anaconda2/etc/jupyter
    /usr/local/etc/jupyter
    /etc/jupyter
data:
    /home/ubuntu/.local/share/jupyter
    /home/ubuntu/anaconda2/share/jupyter
    /usr/local/share/jupyter
    /usr/share/jupyter
runtime:
    /run/user/1000/jupyter

I am getting this error

Unexpected error while saving file: Untitled.ipynb '/home/ubuntu/.local/share/jupyter' exists but is not a directory

Does the file system think it is a directory? [ -d /home/ubuntu/.local/share/jupyter ] && echo "Is a directory"

[ -d /home/ubuntu/.local/share/jupyter ] && echo doesn't give any output.

Then it looks like rm /home/ubuntu/.local/share/jupyter && mkdir /home/ubuntu/.local/share/jupyter should do what we need.

That sounds like you created it as a regular file, not as a directory. I'm not sure what the problem was before. The directory not existing should be fine, because Jupyter tries to create it.

mkdir /home/ubuntu/.local/share/jupyter worked.

So, easy solution but after thinking so much about it.

After creating the folder, I have to change the permissions also by chmod 777 /home/ubuntu/.local/share/jupyter

Thanks guys. The problem is solved.

I mkdir /home/ubuntu/.local/share/jupyter but I still got this problem. @gunjannaik can you tell me more details about your solution ? chmod 777 /home/ubuntu/.local/share/jupyter not work if I don't use sudo mode. Thanks !

Actually I was doing the installation as a root user so I didn't use sudo before chmod.
You can use sudo chmod 777 home/ubuntu/.local/share/jupyter or sudo chmod -R 777 home/ubuntu/.local/share/jupyter.

I think these four steps work for you~
be remember to replace username with your own username in step (3) :
(1) cd ~
(2) sudo rm .local/share/jupyter -rf
(3) sudo chown username:username .local/share/
(4) mkdir .local/share/jupyter

@manhcuogntin4

@liwg06 : i still get
mkdir: cannot create directory ‘.local/share/jupyter’: Permission denied

Try 'Sudo mkdir .local/share/jupyter' or using root access

Don't sudo that, or you'll make a directory owned by root, which your user won't be able to use. You need to check the ownership and permissions on the directories above (~/.local/share) and make sure it's owned by your user.

Ok. If you don't want to use sudo then you can use chown to own the rights of particular folder.

@gunjannaik thanks for the help.
what you mentioned is absolutely correct. I made a slight change, I did rm jupyter -R
from /home/user/.local/share. Then follow your steps.
mkdir /home/ubuntu/.local/share/jupyter and its worked.

My error message was "OSError: [Errno 13] Permission denied: '/home/ubuntu/.local/share/jupyter'"
Not sure if its related but I tried the above-suggested solutions but nothing worked. I then tried jupyter toree install --user and the problem was solved

We need to pass --user arguments if you are working with virutalenv, or the jupyter wasn't installed system wide.

$ jupyter toree install --user --spark_home=<spark_hom_dir>

I'm having the following issue, not sure if it's the same:

Access to the file was denied] The file at /run/user/1000/jupyter/nbserver-6659-open.html is not readable. It may have been removed, moved, or file permissions may be preventing access.

It works when I copy paste the URL, but I want to fix this. It's annoying that running jupyter notebook doesn't open the right thing. neither chown or chmod did anything for me. Tried on the ~/.local/share/jupyter folder as well as the /run/user/1000 one.

See here

I am running a relatively fresh install of Ubuntu and Firefox is my default browser. Would love to solve this, let me know if there's any more info I can give.

EDIT:

https://github.com/jupyter/notebook/issues/4500
Found a fix here.

Was this page helpful?
0 / 5 - 0 ratings