[英]Error occurred while creating new notebook in Jupyter Notebook [Permission Denied]
[英]Jupyter notebook permission error
我在打開 Jupyter 時遇到了一些問題。 我剛剛安裝了 Anaconda,但是當我嘗試在終端中編寫“Jupyter notebook”時遇到了與以前相同的錯誤。
Johans-MBP:~ JDMac$ Jupyter notebook
Traceback (most recent call last):
File "/Users/JDMac/anaconda3/lib/python3.5/site-packages/traitlets/traitlets.py", line 501, in get
value = obj._trait_values[self.name]
KeyError: 'runtime_dir'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/JDMac/anaconda3/bin/jupyter-notebook", line 6, in <module>
sys.exit(notebook.notebookapp.main())
File "/Users/JDMac/anaconda3/lib/python3.5/site-packages/jupyter_core/application.py", line 267, in launch_instance
return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
File "/Users/JDMac/anaconda3/lib/python3.5/site-packages/traitlets/config/application.py", line 588, in launch_instance
app.initialize(argv)
File "<decorator-gen-7>", line 2, in initialize
File "/Users/JDMac/anaconda3/lib/python3.5/site-packages/traitlets/config/application.py", line 74, in catch_config_error
return method(app, *args, **kwargs)
File "/Users/JDMac/anaconda3/lib/python3.5/site-packages/notebook/notebookapp.py", line 1021, in initialize
self.init_configurables()
File "/Users/JDMac/anaconda3/lib/python3.5/site-packages/notebook/notebookapp.py", line 815, in init_configurables
connection_dir=self.runtime_dir,
File "/Users/JDMac/anaconda3/lib/python3.5/site-packages/traitlets/traitlets.py", line 529, in __get__
return self.get(obj, cls)
File "/Users/JDMac/anaconda3/lib/python3.5/site-packages/traitlets/traitlets.py", line 508, in get
value = self._validate(obj, dynamic_default())
File "/Users/JDMac/anaconda3/lib/python3.5/site-packages/jupyter_core/application.py", line 99, in _runtime_dir_default
ensure_dir_exists(rd, mode=0o700)
File "/Users/JDMac/anaconda3/lib/python3.5/site-packages/ipython_genutils/path.py", line 167, in ensure_dir_exists
os.makedirs(path, mode=mode)
File "/Users/JDMac/anaconda3/lib/python3.5/os.py", line 241, in makedirs
mkdir(name, mode)
PermissionError: [Errno 13] Permission denied: '/Users/JDMac/Library/Jupyter/runtime'
由於我對這一切幾乎一無所知,我需要一些幫助:)
解決方案是以普通用戶身份在終端上運行以下命令
$ export XDG_RUNTIME_DIR="" 然后啟動 jupyter $jupyter notebook
它不能作為 root 用戶工作
如果您使用的是 macOS,這可能會對您有所幫助:
sudo chown -R `whoami`:staff ~/Library/Jupyter
>cd..
和>cd yourusername
更改目錄。使用命令
jupyter notebook
這對我有用。
權限錯誤可能是由於目錄不是 777 模式。 請按照以下命令操作,它適用於我:
sudo chmod -R 777 .local
您可以根據目錄中發生的錯誤更改“.local”目錄。
我也遇到過類似的問題:
jupyter notebook
Traceback (most recent call last):
File "c:\p\py353\lib\site-packages\traitlets\traitlets.py", line 528, in get
value = obj._trait_values[self.name]
KeyError: 'log'
...
我使用 PyCharm 安裝 jupyter,所以只需更新jupyter
就可以了。
命令:
pip3 install --upgrade jupyter
如果您再次使用以下命令: pip3 install jupyter 它只是打印已安裝但某些依賴模塊沒有更新
作為根執行:
sudo nano ~/.bashrc
在文件開頭添加:
export XDG_RUNTIME_DIR=""
按Ctrl-o
寫入文件, Ctrl+x
退出。
現在輸入:
source ~/.bashrc
如果這不起作用,請卸載 Jupyter 筆記本並使當前用戶(例如 joe)擁有文件夾中的所有內容(以及文件夾本身):
sudo chown -R $joe:joe /home/joe/.jupyter
pip install notebook --user
當我在 Win 10 中遇到“Jupyter notebook 權限錯誤”時,對我有用的是在管理員模式下運行終端並從那里編寫“Jupyter notebook”。
我運行“whereis jupyter”得到以下輸出:
/snap/bin/jupyter /snap/bin/jupyter.ipython /snap/bin/jupyter.nbconvert
然后我運行以下命令:
sudo chmod -R 755 /snap/bin/jupyter
以前,我試圖為打開 Jupyter 筆記本的文件夾設置權限。 那沒起效。 看來jupyter所在的文件夾需要設置權限。
我遇到了同樣的問題! 然后我打開一個終端並切換到我試圖工作的目錄文件夾並打開 jupyter notebook 並且對我有用。 我的文件夾在 /media 文件夾中。
保羅
我最終在我的 Mac 終端中使用 sudo 打開了我的 Jupyter 筆記本。
sudo jupyter-notebook --allow-root
我嘗試了這篇文章中提出的其他解決方案,這是解決我從 Jupyter 筆記本讀取/保存文件的持久性權限錯誤的解決方案。 當然,這種方法可能會引發一些安全問題,所以我鼓勵其他人在發現任何潛在錯誤時提出批評。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.