python - Errno 13 权限被拒绝。在 jupyter 笔记本,UBUNTU

标签 python ubuntu jupyter-notebook

我新使用“Windows 中的 UBUNTU”并在 UBUNTU 中打开了 jupyter notebook,制作了新的 python3 文件并尝试加载一个名为“Elliptic_main.py”的文件。但是,下面的代码

%load Elliptic_main.py

给出错误信息
---------------------------------------------------------------------------
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'

我认为这是 UBUNTU 的一个问题,但我不确定。有人有同样的问题吗?感谢您的帮助

打字
ls -l Elliptic_main.py

给出以下消息:
---------- 1 sungha sungha 1418 Sep 14 13:54 Elliptic_main.py

这里 sungha 是我的用户名。

最佳答案

来自 ls输出

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

注意
----------

显示设置了哪些权限的部分 (see for example in this wiki for further details)
在您的情况下,您对该文件没有任何权限,这就是您看到 Permission error 的原因

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

查看 chmod 的联机帮助页通过键入 man chmod在您的终端中了解有关两者之间区别的更多详细信息

关于python - Errno 13 权限被拒绝。在 jupyter 笔记本,UBUNTU,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52327864/

相关文章:

python - 从表示图像的数组中排除周围零的最快方法?

python - 为什么自动编码器与编码器 + 解码器的预测不同?

Python 3 : "TypeError: cannot astype a datetimelike from [datetime64[ns]] to [int32]" - Jupyter Notebook

python - Pandas : how do I create a column based on data from the same dataframe?

javascript - javascript 是否有 __repr__ 等价物?

networking - Hadoop Datanodes找不到NameNode

apache - 如何让apache使用python3.6及其模块?

apache - Phabricator 重写规则配置问题

javascript - 为什么jupyter notebook中的kepler map无法在nbviewer上渲染

python - 带有本地 PIL 图像的 Altair 工具提示