I recently freshly installed Ubuntu 14.04 on my laptop, and installed IPython 4 through anaconda. However, I cannot open or load any notebooks, including those that open fine on my desktop. When I try to load a notebook, I get the following error: An unknown error occurred while loading this notebook. This version can load notebook formats v4 or earlier. See the server log for details.
The terminal gives:
Unhandled error in API request
Traceback (most recent call last):
File "/home/ryan/anaconda3/lib/python3.5/site-packages/traitlets/traitlets.py", line 432, in __get__
value = obj._trait_values[self.name]
KeyError: 'db'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/ryan/anaconda3/lib/python3.5/site-packages/notebook/base/handlers.py", line 436, in wrapper
result = yield gen.maybe_future(method(self, *args, **kwargs))
File "/home/ryan/anaconda3/lib/python3.5/site-packages/tornado/gen.py", line 870, in run
value = future.result()
File "/home/ryan/anaconda3/lib/python3.5/site-packages/tornado/concurrent.py", line 215, in result
raise_exc_info(self._exc_info)
File "<string>", line 3, in raise_exc_info
File "/home/ryan/anaconda3/lib/python3.5/site-packages/tornado/gen.py", line 230, in wrapper
yielded = next(result)
File "/home/ryan/anaconda3/lib/python3.5/site-packages/notebook/services/contents/handlers.py", line 126, in get
path=path, type=type, format=format, content=content,
File "/home/ryan/anaconda3/lib/python3.5/site-packages/notebook/services/contents/filemanager.py", line 350, in get
model = self._notebook_model(path, content=content)
File "/home/ryan/anaconda3/lib/python3.5/site-packages/notebook/services/contents/filemanager.py", line 310, in _notebook_model
self.mark_trusted_cells(nb, path)
File "/home/ryan/anaconda3/lib/python3.5/site-packages/notebook/services/contents/manager.py", line 447, in mark_trusted_cells
trusted = self.notary.check_signature(nb)
File "/home/ryan/anaconda3/lib/python3.5/site-packages/nbformat/sign.py", line 220, in check_signature
if self.db is None:
File "/home/ryan/anaconda3/lib/python3.5/site-packages/traitlets/traitlets.py", line 439, in __get__
value = self._validate(obj, dynamic_default())
File "/home/ryan/anaconda3/lib/python3.5/site-packages/nbformat/sign.py", line 126, in _db_default
db = sqlite3.connect(self.db_file, **kwargs)
sqlite3.OperationalError: unable to open database file
When I try to create a new notebook, I get another error that says, Unexpected error while saving file: Dropbox/iPython Notebooks/Untitled.ipynb [Errno 13] Permission denied: '/home/ryan/.local/share/jupyter/notebook_secret'
This seems more informative, but I am relatively new to Linux/python/all this stuff.
The terminal gives:
Error while saving file: Dropbox/iPython Notebooks/Untitled.ipynb [Errno 13] Permission denied: '/home/ryan/.local/share/jupyter/notebook_secret'
Traceback (most recent call last):
File "/home/ryan/anaconda3/lib/python3.5/site-packages/traitlets/traitlets.py", line 432, in __get__
value = obj._trait_values[self.name]
KeyError: 'secret'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/ryan/anaconda3/lib/python3.5/site-packages/notebook/services/contents/filemanager.py", line 387, in save
self.check_and_sign(nb, path)
File "/home/ryan/anaconda3/lib/python3.5/site-packages/notebook/services/contents/manager.py", line 431, in check_and_sign
self.notary.sign(nb)
File "/home/ryan/anaconda3/lib/python3.5/site-packages/nbformat/sign.py", line 245, in sign
signature = self.compute_signature(nb)
File "/home/ryan/anaconda3/lib/python3.5/site-packages/nbformat/sign.py", line 195, in compute_signature
hmac = HMAC(self.secret, digestmod=self.digestmod)
File "/home/ryan/anaconda3/lib/python3.5/site-packages/traitlets/traitlets.py", line 439, in __get__
value = self._validate(obj, dynamic_default())
File "/home/ryan/anaconda3/lib/python3.5/site-packages/nbformat/sign.py", line 173, in _secret_default
self._write_secret_file(secret)
File "/home/ryan/anaconda3/lib/python3.5/site-packages/nbformat/sign.py", line 179, in _write_secret_file
with io.open(self.secret_file, 'wb') as f:
PermissionError: [Errno 13] Permission denied: '/home/ryan/.local/share/jupyter/notebook_secret'
It was suggested that I include the output of python -c "import IPython; print(IPython.sys_info())"
, so here it is:
{'commit_hash': 'f534027',
'commit_source': 'installation',
'default_encoding': 'UTF-8',
'ipython_path': '/home/ryan/anaconda3/lib/python3.5/site-packages/IPython',
'ipython_version': '4.0.0',
'os_name': 'posix',
'platform': 'Linux-3.19.0-33-generic-x86_64-with-debian-jessie-sid',
'sys_executable': '/home/ryan/anaconda3/bin/python',
'sys_platform': 'linux',
'sys_version': '3.5.0 |Anaconda 2.4.0 (64-bit)| (default, Oct 19 2015, '
'21:57:25) \n'
'[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)]'}
As mentioned, I'm not an expert at computing issues. I hope I am not doing something dumb. I have tried uninstalling and reinstalling anaconda, different versions of python, restarting the computer, and I have also tried the solutions found here https://github.com/ipython/ipython/issues/2097 and here https://github.com/ipython/ipython/issues/8294 as they seem similar.
I solved this problem by changing the ownership of the ~/.local/share/jupyter directory from root to user. I don't know why this problem occurred, as it didn't happen on my other systems, so perhaps it's a bug and I will leave this here.
I just did a fresh install and ran into this same problem.
This fix still works.
I used "sudo" before "jupyter notebook --ip 0.0.0.0", and it worked for me.
@metallikapo when I do the same, and if I open a terminal, I am logged in as root. Not good.
Yeah, we don't recommend running the notebook server with sudo
. That will also cause all the code in your notebooks to run as root. Changing the relevant file/directory to be owned by your user, as @rtdew1 found, is a better thing to do. I'm not sure how this situation arises.
i used sudo jupyter notebook in mac it also worked for my system.
@metallikapo thank you very much
i used sudo jupyter notebook in mac it also worked for my system.
@metallikapo thank you very much
Again we don't recommend running with sudo, and notebook 5.0 will refuse to start as root by default, so it is not a solution.
What command did you use?jupyter notebook to open the notebook? I have the same problem with jupyter notebook as well. But using command jupyter-notebook instead solves the problem for me.
how do you change the ownership of jupyter notebook though?
Then what's the better solution? @Carreau
The better solution is to fix the permissions so that Jupyter can run in your regular user account. It's hard to give precise instructions for this, because there are different things that can go wrong and cause similar errors. But in general, you will want to do something like this:
/home/username
on Linux, or /Users/username
on Mac), these instructions apply. If it's somewhere else, the problem might be different.cd
to the folder containing that file.ls -l
to see all the files there. If the file is there, you'll probably see that its owner is root
, instead of your own username. This is the most common problem. If the file is not there, it probably can't create it - go up a level and try the same thing on the directory.sudo chown username:username filename
to change the owner (and group) of the file to your own user. If you're doing this on a directory, use the -R
flag to also change all the files inside it.You can also probably do this from a file manager, but there are loads of different ones, so we won't give instructions.
(In case it wasn't clear, replace username
with your own username in those instructions)
I am running on the Linux system of pynq FPGA and this solves my problem perfectly, thanks! @takluyver
Hi Thomas,
After I execute the code in Jupyter notebook, I encountered another
problem: IPython dir ~/.ipython is not a writable location,using a temp
directory.
Do you know what is going wrong?
Best,
Yu Li
Computer Science and Engineering,
The Chinese University of HongKong,
Shatin, HongKong
2017-11-20 21:01 GMT+08:00 Thomas Kluyver notifications@github.com:
(In case it wasn't clear, replace username with your own username in
those instructions)—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/ipython/ipython/issues/8997#issuecomment-345688870,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AbRY_MLFebh-Y8ruW-vIi-e5ZJHy8H4aks5s4XgjgaJpZM4GkQxG
.
Check the permissions of ~/.ipython
, and try sudo chown username:username ~/ipython
, check also that:
$ ls -al ~/
drwxr-xr-x 14 <username> <usergroup> 476 Oct 9 05:30 .ipython
in particular that the first column start with drwx
if it's not you'll need to sudo chmod o+w ~/.ipython
likely. Where o+w
means add Write permission to Owner.
It's better to chown
that folder to be owned by your user. Using chmod 777
means any user can read or write it. We do store some secret information there, like the database used to track trusted notebooks.
this command works for me:
cd ~ && sudo chown username:username .local/share/
remember to replace username with your own username
@liwg06
This was the correct approach. thanks!
cd ~ && sudo chown username:username .local/share/
HOWEVER,
this wasn't sufficient for me. I had to do back upto .local.
In case of Fedora you might also want to do:
sudo chown -R user:user /run/user/1000/jupyter/
Debian solution that fitted for me:
In the /run/user/1000/jupyter/ folder:
chmod -R 0755 user:user
I ran into the same problem and than I figured out that when I ran pip3 install jupyter command it install jupyter in the current directory which was a root level directory, It would have been bad if I change owner ship of that directory to normal user as that dir was for root , I just uninstalled jupyter and re installed it in my home directory and every thing worked perfectly for me
I'm a win10 user, and I got this error despite the fact that I already am the owner of said directory.
so not sure if this will solve the problem for everyone. I had this same error and none of the solutions worked for me. I check the path to where jupyter was stored using the juypter --path.
there will be a list of paths classified by config, data, and runtime. I cd into a path under config,
looked like this
c:\users\dn.user\appdata\local\programs\python\python37\etc\jupyter
after changing directory to here
I run jupyter again and no error. hope this helps someone
What about Windows user though??
Maybe I should have clarified better. I am a windows user and I used my normal command line
I mean I was using AWS WorkSpace and I face some weird file-location issues due to AWS workspace inner structure!! I figured it out later!! But could you give solution and relative path to resolve the "permission denied" issue for file creation and saving the file!!
Mazior's method helped me fixed it. Thanks!
Same as (XuuLiu commented on 29 Apr 2017) : with Ubuntu 18.04 LS,
using command jupyter-notebook instead solves the problem for me.
None of the above solved it, but I chown user all the sub /.ipynb-checkpoints and that did the trick.
For the windows users:
You need to run the Anaconda prompt Run As Administrator to let you create and modify.
My memory was full. I moved some of the stuff and its working fine now.
ubuntu@ip-172-31-48-131:~/ssl$ jupyter notebook
[I 05:32:07.950 NotebookApp] Loading IPython parallel extension
[I 05:32:07.952 NotebookApp] Serving notebooks from local directory: /home/ubuntu/ssl
[I 05:32:07.952 NotebookApp] The Jupyter Notebook is running at:
[I 05:32:07.952 NotebookApp] https://(ip-172-31-48-131 or 127.0.0.1):8888/
[I 05:32:07.952 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
ERROR:asyncio:Exception in callback BaseAsyncIOLoop._handle_events(4, 1)
handle: <Handle BaseAsyncIOLoop._handle_events(4, 1)>
Traceback (most recent call last):
File "/usr/lib/python3.6/asyncio/events.py", line 145, in _run
self._callback(*self._args)
File "/usr/local/lib/python3.6/dist-packages/tornado/platform/asyncio.py", line 122, in _handle_events
handler_func(fileobj, events)
File "/usr/local/lib/python3.6/dist-packages/tornado/stack_context.py", line 300, in null_wrapper
return fn(*args, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/tornado/netutil.py", line 262, in accept_handler
callback(connection, address)
File "/usr/local/lib/python3.6/dist-packages/tornado/tcpserver.py", line 263, in _handle_connection
do_handshake_on_connect=False)
File "/usr/local/lib/python3.6/dist-packages/tornado/netutil.py", line 565, in ssl_wrap_socket
context = ssl_options_to_context(ssl_options)
File "/usr/local/lib/python3.6/dist-packages/tornado/netutil.py", line 540, in ssl_options_to_context
context.load_cert_chain(ssl_options['certfile'], ssl_options.get('keyfile', None))
PermissionError: [Errno 13] Permission denied
Distributor ID: Ubuntu
Description: Ubuntu 18.04.1 LTS
Release: 18.04
Codename: bionic
# ubuntu@ip-172-31-48-131:~/ssl$ jupyter notebook
ubuntu@ip-172-31-48-131:~/ssl$ sudo jupyter notebook --allow-root
Most helpful comment
I solved this problem by changing the ownership of the ~/.local/share/jupyter directory from root to user. I don't know why this problem occurred, as it didn't happen on my other systems, so perhaps it's a bug and I will leave this here.