17

I'm having some issues with opening Jupyter. I just installed Anaconda, but got the same error as before when I try to write "Jupyter notebook" in terminal.

Johans-MBP:~ JDMac$ Jupyter notebook
Traceback (most recent call last):
  File "/Users/JDMac/anaconda3/lib/python3.5/site-packages/traitlets/traitlets.py", line 501, in get
    value = obj._trait_values[self.name]
KeyError: 'runtime_dir'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/JDMac/anaconda3/bin/jupyter-notebook", line 6, in <module>
    sys.exit(notebook.notebookapp.main())
  File "/Users/JDMac/anaconda3/lib/python3.5/site-packages/jupyter_core/application.py", line 267, in launch_instance
    return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
  File "/Users/JDMac/anaconda3/lib/python3.5/site-packages/traitlets/config/application.py", line 588, in launch_instance
    app.initialize(argv)
  File "<decorator-gen-7>", line 2, in initialize
  File "/Users/JDMac/anaconda3/lib/python3.5/site-packages/traitlets/config/application.py", line 74, in catch_config_error
    return method(app, *args, **kwargs)
  File "/Users/JDMac/anaconda3/lib/python3.5/site-packages/notebook/notebookapp.py", line 1021, in initialize
    self.init_configurables()
  File "/Users/JDMac/anaconda3/lib/python3.5/site-packages/notebook/notebookapp.py", line 815, in init_configurables
    connection_dir=self.runtime_dir,
  File "/Users/JDMac/anaconda3/lib/python3.5/site-packages/traitlets/traitlets.py", line 529, in __get__
    return self.get(obj, cls)
  File "/Users/JDMac/anaconda3/lib/python3.5/site-packages/traitlets/traitlets.py", line 508, in get
    value = self._validate(obj, dynamic_default())
  File "/Users/JDMac/anaconda3/lib/python3.5/site-packages/jupyter_core/application.py", line 99, in _runtime_dir_default
    ensure_dir_exists(rd, mode=0o700)
  File "/Users/JDMac/anaconda3/lib/python3.5/site-packages/ipython_genutils/path.py", line 167, in ensure_dir_exists
    os.makedirs(path, mode=mode)
  File "/Users/JDMac/anaconda3/lib/python3.5/os.py", line 241, in makedirs
    mkdir(name, mode)
PermissionError: [Errno 13] Permission denied: '/Users/JDMac/Library/Jupyter/runtime'

As I'm close to clueless with all of this, I need some assistance over here :)

joddm
  • 589
  • 1
  • 6
  • 18

11 Answers11

17

the solution is run the following command on the terminal as a normal user

$ export XDG_RUNTIME_DIR=""

then start the jupyter

$jupyter notebook

it will not work as root user

Anik Islam Abhi
  • 25,137
  • 8
  • 58
  • 80
Dejene
  • 195
  • 1
  • 2
11

If you are using macOS, this may help you:

sudo chown -R `whoami`:staff ~/Library/Jupyter
TheDudeAbides
  • 1,821
  • 1
  • 21
  • 29
joddm
  • 589
  • 1
  • 6
  • 18
  • I don't see any folder named `Jupyter`. Just a `.jupyter`. And it is already owned by my current user. Any clues about which file needs to be owned ? – davneetnarang Oct 07 '16 at 16:22
  • Sorry, I don't understand, you experience this error yourself or is it a correction? @davneet – joddm Oct 25 '16 at 11:28
  • It would be more useful if you could copy the error message etc. you get when you're trying to run it. @davneet – joddm Oct 25 '16 at 14:12
  • By 'error' I meant 'problem' and not an actual error message. I mean I can't see `~/Library/Jupyter` on my filesystem. And so I am not running the command at all. Because I don't have that folder anywhere. – davneetnarang Oct 26 '16 at 10:38
  • 1
    @davneet you probably you don't have MacOS ... the folders mentioned in the answer are the file structure on Mac OS. – Verena Haunschmid Jan 12 '17 at 06:38
  • @davneet If you still have this issue you probably created some files using sudo (in case you're on Linux) or some other account than the one you're using now. Check with `ls -lah` who the files in `.jupyter` and other related directories belong to. In my case the problem were check point files in .ipybn_checkpoints (this is located in the directory from where you start `jupyter notebook`). – Verena Haunschmid Jan 12 '17 at 06:45
2
  1. You may be working under the initial installers userid
  2. Go to Ananconda prompt and change directory with these 2 commands >cd.. and >cd yourusername.
  3. Use the command

    jupyter notebook

This worked for me.

Miriam Farber
  • 18,986
  • 14
  • 61
  • 76
SJ5823
  • 21
  • 1
1

I also met a similar problem like this:

jupyter notebook
Traceback (most recent call last):
  File "c:\p\py353\lib\site-packages\traitlets\traitlets.py", line 528, in get
    value = obj._trait_values[self.name]
KeyError: 'log'
...

I install jupyter use PyCharm so just update jupyter and It was sovled.

command:

pip3 install --upgrade jupyter

if you use command below again: pip3 install jupyter it just print already installed but some dependent modules didn‘t update

lemmingxuan
  • 549
  • 1
  • 7
  • 18
  • 2
    It did solve me problem: ```Error executing Jupyter command 'notebook': [Errno 13] Permission denied``` when run ```jupyter notebook``` – Pengju Zhao Jul 24 '17 at 08:31
  • so why it did solve the problem and some people vote “this answer is not useful”, are they so aggressive? – lemmingxuan Jul 30 '21 at 01:39
1

The permission error may be due to directory is not in 777 mode. Please follow below command, it works for me:

sudo chmod -R 777 .local

You can change ".local" directory according to error occurred in your directory.

Nisan Chhetri
  • 339
  • 3
  • 3
  • 13
    Please do not do this. The command `chmod -R 777 .local` makes `~/.local` world-writable. At best, this is a chainsaw solution to a penknife problem; at worst (on a multi-user system), it's a gaping security hole. – TheDudeAbides Oct 09 '19 at 18:58
  • If your aim is to make everything under `~/.local` read/writable by your user (because the permissions got messed up somehow), a better solution would be `find ~/.local -type d -exec chmod u+rwx +; find ~/.local -type f -exec chmod u+rw +`. This sets directories read/write/execute (meaning you can `cd` into them), and files read/write, for the user only. – TheDudeAbides Oct 09 '19 at 18:58
0

As a root execute:

sudo nano  ~/.bashrc

Add at the begining of the file:

 export XDG_RUNTIME_DIR="" 

Press Ctrl-o to write file and Ctrl+x to exit.

Now type:

source ~/.bashrc 

If that doesn't work uninstall Jupyter notebook and make the current user (joe for example) own everything inside the folder (and the folder itself):

sudo chown -R $joe:joe /home/joe/.jupyter

pip install notebook --user
Hrvoje
  • 13,566
  • 7
  • 90
  • 104
0

What worked for me when I got the "Jupyter notebook permission error" in Win 10, was running the terminal in Administrator mode and writing "Jupyter notebook" from there.

Igal L
  • 91
  • 5
0

I ran "whereis jupyter" to get the following output:

/snap/bin/jupyter /snap/bin/jupyter.ipython /snap/bin/jupyter.nbconvert

Then I ran the following command:

sudo chmod -R 755 /snap/bin/jupyter

Previously, I was trying to set the permission for the folder where I was opening a Jupyter notebook. It did not work. It seems that the permission needs to be set for the folder where jupyter is located.

smsarwar
  • 351
  • 3
  • 3
0

I was having the same problem! Then I opened a terminal and changed to the directory folder that I was trying to work and opened the jupyter notebook and that worked for me. My folder was in the /media folder.

Paulo

0

I ended up opening up my Jupyter notebook using sudo in my terminal of my Mac.

sudo jupyter-notebook --allow-root

I tried the other solutions proposed in this post and this was the one that worked for me in solving my persistent permission errors for reading/saving files from my Jupyter notebook. Granted this approach might raise some security concerns, so I encourage others to provide critique if they find any potential fault in it.

Bob McBobson
  • 743
  • 1
  • 9
  • 29
0

I got it trying to run jupyter lab installed by my previous windows user account.

Fixed by manual deletion of User\AppData\Roaming\jupyter,
jupyter will recreate it at the start (note: my users have admin rights).