[英]How to grant Access for File Handling in Jupyter Notebook? [Permission Denied Error]
[英]Jupyter Notebook: Access to the file was denied
我正在尝试在 Ubuntu 21.10 上运行 Jupyter 笔记本。 我已经安装了 python、jupyter notebook 和所有各种先决条件。 我将export PATH=$PATH:~/.local/bin
添加到我的bashrc
中,以便命令jupyter notebook
可以从终端运行。
当我从终端调用jupyter notebook
时,我从浏览器收到以下错误消息:
Access to the file was denied.
The file at /home/username/.local/share/jupyter/runtime/nbserver-260094-open.html is not readable.
It may have been removed, moved, or file permissions may be preventing access.
我正在使用最新版本的 FireFox。
我已经阅读了许多关于这方面的指南,这似乎是一个权限错误,但我使用的指南都没有解决这个问题。 使用sudo
没有帮助,实际上它会导致Exception: Jupyter command "jupyter-notebook" not found.
被抛出。
话虽如此,我仍然能够访问笔记本服务器。 如果我将 go 连接到终端,而是单击笔记本服务器的localhost:8888
或 IP 地址,那么它会将我带到笔记本电脑,一切运行都没有问题。
我想解决这个问题,这样当我运行jupyter notebook
时,我被带到服务器,不需要 go 回到终端 window 并单击 IP 地址。 如果我同时运行多个笔记本,这很不方便并且会减慢我的速度。
对此问题的任何帮助将不胜感激!
我有同样的问题。
Ubuntu 20.04.3 LTS 铬版 96.0.4664.110
这是我的解决方案:
使用以下命令创建配置文件:
jupyter notebook --generate-config
编辑配置文件~/.jupyter/jupyter_notebook_config.py
并设置:
c.NotebookApp.use_redirect_file = False
确保此配置参数从行首开始。 如果在行首留一个空格,您将收到拒绝访问文件的消息。
否则,您可以清理并重新安装 JupyterLab
jupyter lab clean --all
pip3 install jupyterlab --force-reinstall
如果有人好奇,问题的原因是file://
URI 方案无法直接访问主目录下的隐藏目录中的文件(在您的情况下为~/.local
)。
您可以使用以下命令重新创建问题: mkdir ~/.test && echo "abc" > ~/.test/file.html && xdg-open ~/.test/file.html
我在RFC8089中找不到此行为的任何参考资料,而且我也不明白 Jupyter 作者是如何错过这个问题的。
正如 LSeu 建议的那样,绕过本地重定向文件的方法是运行: echo "c.NotebookApp.use_redirect_file = False" >> ~/.jupyter/jupyter_notebook_config.py
另一种解决方案是运行jupyter notebook --no-browser
并 (Ctrl)-单击终端中的链接。
尝试这个
sudo nano ~/.bashrc
在文件开头添加:
export XDG_RUNTIME_DIR=""
按 Ctrl-o 写入文件,按 Ctrl+x 退出。
现在输入:
source ~/.bashrc
对于那些运行 Firefox 并安装了 snap 的用户:
我认为这个问题与安装了 Snap 的 firefox 有更多关系,在此过程中某处不允许 Firefox 访问其沙盒环境中 /home/user 文件夹内的隐藏目录。
此线程中未提及的另一个解决方案(如果您不想使用其他浏览器安装)是将JUPYTER_RUNTIME_DIR
变量设置为/home/user
文件夹中的非隐藏目录:
# Ubuntu 22.04.1 LTS
# append env variable to persistent user env file. requires relogging in
echo JUPYTER_RUNTIME_DIR=/home/user/jupyter_runtime >> ~/.pam_environment
reboot
或者,尝试直接访问其他建议的 URL: http://localhost:8888/lab?token=<your-access-token>
或http://127.0.0.1:8888/lab?token=<your-access-token>
(这是设置...use_redirect_file = False
所做的
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.