简体   繁体   中英

Errno 13 Permission denied. in jupyter notebook, UBUNTU

I'm newly using 'UBUNTU in windows' and opened jupyter notebook inside UBUNTU, make new python3 file and try to load a file named 'Elliptic_main.py'. However, the following code

%load Elliptic_main.py

gives error messages

---------------------------------------------------------------------------
PermissionError                           Traceback (most recent call last)
<ipython-input-1-69cbacf526f9> in <module>()
----> 1 get_ipython().run_line_magic('load', 'Elliptic_main.py')

~/.local/lib/python3.6/site-packages/IPython/core/interactiveshell.py in run_line_magic(self, magic_name, line, _stack_depth)
   2129                 kwargs['local_ns'] = sys._getframe(stack_depth).f_locals
   2130             with self.builtin_trap:
-> 2131                 result = fn(*args,**kwargs)
   2132             return result
   2133 

<decorator-gen-47> in load(self, arg_s)

~/.local/lib/python3.6/site-packages/IPython/core/magic.py in <lambda>(f, *a, **k)
    185     # but it's overkill for just that one bit of state.
    186     def magic_deco(arg):
--> 187         call = lambda f, *a, **k: f(*a, **k)
    188 
    189         if callable(arg):

~/.local/lib/python3.6/site-packages/IPython/core/magics/code.py in load(self, arg_s)
    333         search_ns = 'n' in opts
    334 
--> 335         contents = self.shell.find_user_code(args, search_ns=search_ns)
    336 
    337         if 's' in opts:

~/.local/lib/python3.6/site-packages/IPython/core/interactiveshell.py in find_user_code(self, target, raw, py_only, skip_encoding_cookie, search_ns)
   3263             if os.path.isfile(tgt):                        # Read file
   3264                 try :
-> 3265                     return openpy.read_py_file(tgt, skip_encoding_cookie=skip_encoding_cookie)
   3266                 except UnicodeDecodeError :
   3267                     if not py_only :

~/.local/lib/python3.6/site-packages/IPython/utils/openpy.py in read_py_file(filename, skip_encoding_cookie)
     74     A unicode string containing the contents of the file.
     75     """
---> 76     with open(filename) as f:   # the open function defined in this module.
     77         if skip_encoding_cookie:
     78             return "".join(strip_encoding_cookie(f))

~/anaconda3/lib/python3.6/tokenize.py in open(filename)
    450     detect_encoding().
    451     """
--> 452     buffer = _builtin_open(filename, 'rb')
    453     try:
    454         encoding, lines = detect_encoding(buffer.readline)

PermissionError: [Errno 13] Permission denied: 'Elliptic_main.py'

I think this is an issue for UBUNTU, but I'm not sure. Anyone has same issue? Thanks for any helps


typing

ls -l Elliptic_main.py

gives the following message:

---------- 1 sungha sungha 1418 Sep 14 13:54 Elliptic_main.py

here sungha is my user name.

From the ls output

---------- 1 sungha sungha 1418 Sep 14 13:54 Elliptic_main.py

Notice the

----------

part that shows which permissions are set ( see for example in this wiki for further details ) In your case you don't have ANY permissions on that file which is why you see Permission error

Try

chmod 600 # in case sungha is your username
chmod 666 # otherwise

Check the manpage of chmod by typing man chmod in your terminal for further details on what the difference is between the two

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM