Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PermissionError: [Errno 13] Permission denied when running jupyter notebook on bash #3608

Closed
1yc opened this issue Oct 11, 2018 · 20 comments
Closed

Comments

@1yc
Copy link

1yc commented Oct 11, 2018

I am using jupyter notebook for the first time but when I finished all the installation the following error message occurs on bash:

[E 09:19:54.020 NotebookApp] Uncaught exception GET /api/contents?type=directory&=1539220793912 (127.0.0.1)
HTTPServerRequest(protocol='http', host='localhost:8888', method='GET', uri='/api/contents?type=directory&
=1539220793912', version='HTTP/1.1', remote_ip='127.0.0.1')
Traceback (most recent call last):
File "/home/l_yc/.local/lib/python3.5/site-packages/tornado/web.py", line 1592, in _execute
result = yield result
File "/home/l_yc/.local/lib/python3.5/site-packages/tornado/gen.py", line 1133, in run
value = future.result()
File "/home/l_yc/anaconda3/lib/python3.5/asyncio/futures.py", line 274, in result
raise self._exception
File "/home/l_yc/.local/lib/python3.5/site-packages/tornado/gen.py", line 326, in wrapper
yielded = next(result)
File "/home/l_yc/.local/lib/python3.5/site-packages/notebook/services/contents/handlers.py", line 112, in get
path=path, type=type, format=format, content=content,
File "/home/l_yc/.local/lib/python3.5/site-packages/notebook/services/contents/filemanager.py", line 431, in get
model = self._dir_model(path, content=content)
File "/home/l_yc/.local/lib/python3.5/site-packages/notebook/services/contents/filemanager.py", line 337, in _dir_model
if self.should_list(name) and not is_file_hidden(os_path, stat_res=st):
File "/home/l_yc/.local/lib/python3.5/site-packages/notebook/utils.py", line 145, in is_file_hidden_posix
stat_res = os.stat(abs_path)
PermissionError: [Errno 13] Permission denied: '/mnt/c/Users/lyc78/Application Data'

How can I fix the permission on this folder in a comparatively safe manner?

@1yc
Copy link
Author

1yc commented Oct 11, 2018

[E 09:26:44.260 NotebookApp] {
"X-Requested-With": "XMLHttpRequest",
"Accept-Encoding": "gzip, deflate, br",
"Accept": "application/json, text/javascript, /; q=0.01",
"Host": "localhost:8888",
"X-Xsrftoken": "2|1b30e5f3|119bfccb9f618430a054e0e098cb0797|1539178348",
"Accept-Language": "zh-CN,zh;q=0.9,ja;q=0.8",
"Connection": "keep-alive",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36",
"Referer": "http://localhost:8888/tree",
"Cookie": "_xsrf=2|1b30e5f3|119bfccb9f618430a054e0e098cb0797|1539178348; username-localhost-8888="2|1:0|10:1539220793|23:username-localhost-8888|44:NTllYTg0NjJkY2FlNGUyOTgxNTNhZDA2ZjBhNTQxMWI=|d0a4865c2dd710cc41bf1b37f038443636d06fd0a01631ef6a5949f2b1d7b9c8""
}

@malwareslayer
Copy link

malwareslayer commented Oct 20, 2018

Try Run Wsl With Administrator ?
If same, the temporary problem should running jupyter with root / sudo user.
sudo jupyter-notebook --allow-root

@adamhaber
Copy link

I get exactly the same error... anyone found a solution for this one?

Some additional details: Jupyter works perfectly within WSL filesystem. However, when I cd /mnt/c/Users/adamh/ and try to run jupyter notebook from there, I get the error message above. Trying to symlink /mnt/c/Users/adamh/ into WSL home dir didn't help, either.

Running jupyter with --allow-root didn't help, and running it with sudo gave sudo: jupyter: command not found.

@1yc
Copy link
Author

1yc commented Dec 23, 2018

Well running with administrator does no work and I am now using jupyter on windows lol

@adamhaber
Copy link

I'm using a library that doesn't have windows support, so unfortunately this is not an option for me... :-\

@1yc
Copy link
Author

1yc commented Dec 23, 2018

emmm why not directly use linux? it seems that jupyter doesn;t work so well on wsl

@adamhaber
Copy link

adamhaber commented Dec 23, 2018 via email

@1yc
Copy link
Author

1yc commented Dec 23, 2018

Good luck~

@YoheiFukuhara
Copy link

I got a same error.
I changed current directory from /mnt/c/Users/ to /home// and run jupiter notebook.
Then jupyter successfully started.

@diallobakary4
Copy link

diallobakary4 commented Jan 7, 2019

I am having the same problem.
I am Windows Linux subsystem installed Windows on 10 and installed Anaconda3-2018.12-Linux-x86_64.
After trying different directories for "c.NotebookApp.notebook_dir =" :

PermissionError: [Errno 13] Permission denied: '/mnt/c/Users/Bakary/Documents/My Music'
PermissionError: [Errno 13] Permission denied: '/mnt/c/Users/Bakary/Application Data'
PermissionError: [Errno 13] Permission denied: '/mnt/c/Documents and Settings'

I have noticed that Jupyter lab complains about Windows system-specific directories such as Documents and Settings, My Music... But it works fine on a created directory in Documents.
/mnt/c/Users/Bakary/Documents/HD
The previous directories seem to have a special permission.
Launching the WLS in admin mode doesn't work.

emmm why not directly use linux? it seems that jupyter doesn;t work so well on wsl

@1yc do you know any other problem related to WLS. I was using Jupyterlab windows version and started migrating toward the WLS to have a bash terminal integrated and for some packages also. I would like to be aware of any future possible problem.

@dsaffo
Copy link

dsaffo commented Jan 11, 2019

I am having the same issue, the only work around I found was launching the notebook from a different drive other than my boot drive. I guess this wont help laptop users but maybe creating a partition will have the same effect.

@KChalk
Copy link

KChalk commented Jan 22, 2019

Open a subfolder which does not contain any windows folders. In my case this means running jupyter notebook from /mnt/c/Users/me/Documents/Classes instead of /mnt/c/Users/me/

Hope that helps.

@realchrisolin
Copy link

realchrisolin commented Apr 5, 2019

I ran into this same issue and came up with a really hacky workaround. Backup /usr/local/lib/python3.7/dist-packages/notebook/utils.py (just in case) and edit the beginning of is_file_hidden_posix() (around line 164) to look like the code below, specifically, the changes to the first try/except block:

def is_file_hidden_posix(abs_path, stat_res=None):
    """Is a file hidden?

    This only checks the file itself; it should be called in combination with
    checking the directory containing the file.

    Use is_hidden() instead to check the file and its parent directories.

    Parameters
    ----------
    abs_path : unicode
        The absolute path to check.
    stat_res : os.stat_result, optional
        The result of calling stat() on abs_path. If not passed, this function
        will call stat() internally.
    """
    if os.path.basename(abs_path).startswith('.'):
        return True

    if stat_res is None or stat.S_ISLNK(stat_res.st_mode):
        try:
            stat_res = os.stat(abs_path)
        except (PermissionError, OSError) as e:
            if isinstance(e, PermissionError):
                pass
            elif e.errno == errno.ENOENT:
                return False
            else
                raise

This is caused by #2779. Since trying to access them throws a PermissionError and I'm pressed for time, this "workaround" simply squelches the exception and keeps running. There's probably a better way to do this by somehow detecting if abs_path is pointing to a directory or a built-in NTFS junction and skipping it if it's the latter.

The less nuclear workaround is what a couple others have pointed out. Run jupyter from a subdirectory and not the root of your home dir.

@therealkenc
Copy link
Collaborator

Great investigation, thanks. Maybe add a short note detailing the Jupyter problem over in #2779 (which is at least open). This issue was closed because there was no effort at all given to provide CLI reproduction steps or fill in the template. You've got an actual hard fail here, as opposed to ls(1) which suffers from being in the "annoying but not fatal" category, and thus (I imagine) has trouble getting much of a rise out of anyone in Redmond versus other issues to choose from. That might or might not result in a timely fix, but it sure won't hurt.

@anabeto93
Copy link

anabeto93 commented May 8, 2019

What I discovered is simple. Change directory to something else, away from the home directory (eg. /c/Users/) and instead move somewhere such as /d/Codes/Python

@sxz-ivan
Copy link

I'm getting the 'permission denied' error for jupyter_notebook_config.py at jupyter startup on wsl. chmod on this file solves the problem. Citing: https://blog.csdn.net/sudakuang/article/details/78298320

@dantravers
Copy link

As per above, I found the issues was as in #2779 but I would easily get work around to get to the directory I wanted if rather than navigate through each directory in Jupyter folder system UI, I jumped straight over the directories giving the problem: http://localhost:8888/tree/dtravers/winhome/
to:
http://localhost:8888/tree/dtravers/winhome/GoogleDrive/Projects

@StephJones87
Copy link

That's my current solution... but I'd love to use WSL for this. Guess I'll have to wait and see if this is solved in the future...

On Sun, Dec 23, 2018 at 11:11 AM 1yc @.***> wrote: emmm why not directly use linux? it seems that jupyter doesn;t work so well on wsl — You are receiving this because you commented. Reply to this email directly, view it on GitHub <#3608 (comment)>, or mute the thread https://github.com/notifications/unsubscribe-auth/ATYQksp_uCvdWiYTTfAh81OJfYUHdS0Vks5u70i_gaJpZM4XWnBj .

did you manage to fix this issue?

@nobynobita
Copy link

i am getting this error plzz help me

@h0oper
Copy link

h0oper commented Aug 5, 2020

running "chmod -R 777" on "/home/yourdirectory" fixed this for me, as well any other permission problems i had running python scripts from jupyter notebooks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests