2

I installed jupyter notebook via conda on my ubuntu. Now, whenever I try to save my Jupiter notebook it gives me error 13: permission denied.

Saving file at /Documents/Ship-radiated-noise-estimation-using-AI/Random Forest.ipynb
[W 17:57:46.124 NotebookApp] Unexpected error while saving file: Documents/Ship-radiated-noise-estimation-using-AI/Random Forest.ipynb [Errno 13] Permission denied: '/home/avi/Documents/Ship-radiated-noise-estimation-using-AI/.ipynb_checkpoints/Random Forest-checkpoint.ipynb'
[E 17:57:46.125 NotebookApp] {
      "Host": "localhost:8888",
      "Connection": "keep-alive",
      "Content-Length": "57866",
      "Accept": "application/json, text/javascript, */*; q=0.01",
      "X-Requested-With": "XMLHttpRequest",
      "X-Xsrftoken": "2|054c4e1d|fe934c5c5e2843c9e5dab551f16ed9a5|1591886911",
      "User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.97 Safari/537.36",
      "Content-Type": "application/json",
      "Origin": "http://localhost:8888",
      "Sec-Fetch-Site": "same-origin",
      "Sec-Fetch-Mode": "cors",
      "Sec-Fetch-Dest": "empty",
      "Referer": "http://localhost:8888/notebooks/Documents/Ship-radiated-noise-estimation-using-AI/Random%20Forest.ipynb",
      "Accept-Encoding": "gzip, deflate, br",
      "Accept-Language": "en-GB,en-US;q=0.9,en;q=0.8",
      "Cookie": "_xsrf=2|054c4e1d|fe934c5c5e2843c9e5dab551f16ed9a5|1591886911; username-localhost-8889=\"2|1:0|10:1592913160|23:username-localhost-8889|44:MDJhM2JjOGJlOTFmNDAwZDg3YzE1ZjU5MzRhZjA3NWE=|2f443fc34809baea4742ba6589e1faf479105f8d6b3518a3583265a16f72888b\"; username-localhost-8888=\"2|1:0|10:1593080616|23:username-localhost-8888|44:Y2M1ZmVkNzEwNWM0NGJiZGFmNDYwNWNlMzVhMTdmNmU=|2692cec91ce0a49620300d2b09fca623208a50442f0e0fcc39c764de38160930\""
    }
[E 17:57:46.125 NotebookApp] 500 PUT /api/contents/Documents/Ship-radiated-noise-estimation-using-AI/Random%20Forest.ipynb (127.0.0.1) 1692.03ms referer=http://localhost:8888/notebooks/Documents/Ship-radiated-noise-estimation-using-AI/Random%20Forest.ipynb
Mohnish
  • 1,010
  • 1
  • 12
  • 20
XProtocol
  • 21
  • 1
  • 1
  • 8
  • Are you sure the /Documents folder exists ? It may be ~/Documents, where `~` is a link to your user home directory. The absolute path would be `/home/username/Documents/` – totok Jun 25 '20 at 12:36
  • How can I check that? – XProtocol Jun 25 '20 at 12:38
  • Open a command prompt and try accessing `/Documents` : ```cd /Documents``` If you have an error, that means that the folder doesn't exists, and that the problem is here. You may add a prefix to the save path so it redirect it to your home directory – totok Jun 25 '20 at 12:39
  • Yep, it is showing that /Documents do not exist. I'm new to ubuntu so I don't know how to add prefix to the save path. Can you please tell or give any tutorial link to which I can refer? – XProtocol Jun 25 '20 at 12:43
  • According to [this](https://jupyter.readthedocs.io/en/latest/projects/jupyter-directories.html) documentation page, you can find the jupyter config directory with the following command : `jupyter --paths` or `jupyter --config-dir`. Find the `JUPYTER_DATA_DIR` environment variable and tell me what it is. If it doesn't exist or if it's `/`, set this environment variable to `/home/your_username/Documents/`. You can search on the internet to know how to set an environment variable. Then restart jupyter – totok Jun 25 '20 at 12:50
  • You can also try printing `JUPYTER_DATA_DIR` with the following command : `printenv | grep JUPYTER_DATA_DIR` – totok Jun 25 '20 at 12:58
  • I went through the documentation and for JUPYTER_DATA_DIR I used jupyter --data-dir. And it showing /home/avi/.local/share/jupyter. – XProtocol Jun 25 '20 at 13:02
  • Can you check the rights and ownership of this folder ? `ls -lA /home/avi/.local/share | grep jupyter` – totok Jun 25 '20 at 13:14
  • It gave me this -> drwxrwxr-x 6 avi avi 4096 Jun 25 18:40 jupyter – XProtocol Jun 25 '20 at 13:16
  • try giving write access to the folder to the jupyter user (and everyone else) : ```chmod 777 -R /home/avi/.local/share/jupyter``` – totok Jun 25 '20 at 13:32
  • Copy pasted the command. Didn't work – XProtocol Jun 25 '20 at 13:41
  • Did you restart jupyter-lab ? – totok Jun 25 '20 at 14:27
  • I closed notebook by ctrl +C and then pressed y to confirm and restarted it by typing Jupiter notebook in the terminal. I'm not sure does this not restart jupyter-lab? – XProtocol Jun 25 '20 at 14:36
  • Have you tried the solution proposed by @marneylc in [this SO question](https://stackoverflow.com/questions/35254852/how-to-change-the-jupyter-start-up-folder) : Generate a config file, and set the starting directory where you want – totok Jun 25 '20 at 15:19

2 Answers2

0

You would need to change the permissions of the following directory from the root to a user.

~/.local/share/jupyter

Hope that works fixes your issue

0

I found a way to fix this but this answer might only be appropriate for my situation.

So, the reason for the problem is that I first installed Jupyter notebook using pip and later on I installed it using anaconda because if I recall correctly I couldn't properly configure the installed using pip due to which I used conda. So below is how I fixed the problem.

First I uninstalled conda. By using these cmds

    rm -rf ~/anaconda3
    rm -rf ~/.condarc ~/.conda ~/.continuum

and edited ~/.bachrc to remove Anaconda directory from the PATH environment variable by deleting

    # added by Anaconda3 installer
    export PATH="/home/linuxize/anaconda3/bin:$PATH"

I used all these cmd in terminal

    pip3 uninstall jupyter
    pip3 uninstall jupyter_core
    pip3 uninstall jupyter-client
    pip3 uninstall jupyter-console
    pip3 uninstall notebook
    pip3 uninstall qtconsole
    pip3 uninstall nbconvert
    pip3 uninstall nbformat

Then I went to /usr/local/lib/python3.8/dist-packages and deleted all the directories which were of jupyter, notebook, etc and then deleted python files related to jupyter in pycache directory.

Then I finally reinstalled anaconda. I'm not sure which steps were or weren't necessary but this fixed my problem.

XProtocol
  • 21
  • 1
  • 1
  • 8