Python Jupyter Notebook 未保存:帖子中缺少“_xsrf”参数
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/55014094/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Jupyter Notebook not saving: '_xsrf' argument missing from post
提问by V P
I've been running a script on jupyter notebooks for about 26 hour; I haven't really been using my computer for anything else, but it needs to run this program that will take ~30 hours to complete. At about 21 hours in, it stopped saving and my terminal had this:
我已经在 jupyter 笔记本上运行脚本大约 26 小时了;我并没有真正将我的计算机用于其他任何用途,但是它需要运行这个程序,该程序需要大约 30 个小时才能完成。在大约 21 小时后,它停止保存,我的终端有这个:
403 PUT /api/contents/[file.ipynb] (::1): '_xsrf' argument missing from POST
where [file.ipynb] is the location of my jupyter notebook. It also says:
其中 [file.ipynb] 是我的 jupyter 笔记本的位置。它还说:
'_xsrf' argument missing from post
in the top right part of the notebook again. The program is still running and I don't want to restart jupyter notebook and have to run the program again, as I have a deadline, is there anything else I can do?
再次在笔记本的右上角。该程序仍在运行,我不想重新启动 jupyter notebook 而不得不再次运行该程序,因为我有一个截止日期,还有什么我可以做的吗?
I'm using google chrome, but I don't have the LastPass extension or any '%' characters in my code, as another post suggested.
我正在使用谷歌浏览器,但正如另一篇文章所建议的那样,我的代码中没有 LastPass 扩展名或任何“%”字符。
Thanks for any help!
谢谢你的帮助!
回答by caxcaxcoatl
The easiest way I found is this:
我找到的最简单的方法是这样的:
https://github.com/nteract/hydrogen/issues/922#issuecomment-405456346
https://github.com/nteract/hydrogen/issues/922#issuecomment-405456346
Just open another notebook on the same kernel, and the issue is magically gone; you can again save the notebooks that were previously showing the _xsrf
error.
只需在同一内核上打开另一个笔记本,问题就神奇地消失了;您可以再次保存以前显示_xsrf
错误的笔记本。
If you have already closed the Jupyter home page, you can find a link to it on the terminal from which Jupyter was started.
如果您已经关闭了 Jupyter 主页,您可以在启动 Jupyter 的终端上找到它的链接。
回答by GDB
The solution I came across seems too simple but it worked. Go to the /tree aka Jupyter home page and refresh the browser. Worked.
我遇到的解决方案似乎太简单了,但它奏效了。转到 /tree 又名 Jupyter 主页并刷新浏览器。工作了。
回答by Biggsy
I use jupyter notebooks daily and had never experienced this issue before... until today. I had the notebook open all day but it wasn't running anything and then for no apparent reason stopped auto-saving with the '_xsrf' argument missing from POST
error message in the top right. FYI - this is a python3 notebook.
我每天都使用 jupyter 笔记本,之前从未遇到过这个问题……直到今天。我整天打开笔记本,但它没有运行任何东西,然后无缘无故地停止自动保存,'_xsrf' argument missing from POST
右上角显示错误消息。仅供参考 - 这是一个 python3 笔记本。
I don't know the cause of this problem but I have recently upgraded my python3 version to 3.7.2 and upgraded all of my site-packages to their latest version as of a few days ago which could possibly be the cause.
我不知道这个问题的原因,但我最近将我的 python3 版本升级到 3.7.2,并将我所有的站点包升级到几天前的最新版本,这可能是原因。
As for a solution, as suggested in the comment by @AlexK, I opened the same notebook in a new window (different browser in fact), using
至于解决方案,正如@AlexK 在评论中所建议的,我在新窗口(实际上是不同的浏览器)中打开了同一个笔记本,使用
jupyter notebook list
in the terminal to get the URL with login token.
在终端中获取带有登录令牌的 URL。
This resulted in me having the notebook open and savable again but the information I had entered since the last successful auto-save was missing. Thankfully, my broken instance was still open and working apart from saving so I was able to simply copy and paste the information across then hit save. So, keep the broken instance open if you try this!
这导致我再次打开并保存了笔记本,但自从上次成功自动保存以来我输入的信息丢失了。值得庆幸的是,我损坏的实例仍然处于打开状态,除了保存之外还可以正常工作,因此我可以简单地复制和粘贴信息,然后点击保存。因此,如果您尝试此操作,请将损坏的实例保持打开状态!
回答by Richard Liang
When I click 'save' button, it has this error. Based on the answers in this post and other websites, I just found the solution. My jupyter notebook is installed from pip. So I access it by typing 'jupyter notebook' in the windows command line.
当我单击“保存”按钮时,出现此错误。根据这篇文章和其他网站中的答案,我刚刚找到了解决方案。我的 jupyter 笔记本是从 pip 安装的。所以我通过在 Windows 命令行中输入“jupyter notebook”来访问它。
(1) open a new command window, then open a new jupyter notebook. try to save again in the old notebook, this time ,the error is 'fail: forbidden'
(1) 打开一个新的命令窗口,然后打开一个新的 jupyter notebook。尝试再次保存在旧笔记本中,这一次,错误是“失败:禁止”
(2) Then in the old notebook, click 'download as', it will pop out a new windows ask you the token.
(2) 然后在旧笔记本中,单击“下载为”,它会弹出一个新窗口询问您的令牌。
(3) open another command window, then open another jupyter notebook, type 'jupyter notebook list' copy the code after 'token=' and before :: to the box you just saw. You can save this time. If it fails, you can try another token in the list
(3) 打开另一个命令窗口,然后打开另一个jupyter notebook,输入'jupyter notebook list',将'token='之后和::之前的代码复制到你刚刚看到的框中。你可以节省这个时间。如果失败,您可以尝试列表中的另一个令牌
回答by Toru Kikuchi
In my case, this problem was solved by clicking 'Kernel' (shown on the top of notebooks) and then 'Reconnect'.
就我而言,这个问题是通过单击“内核”(显示在笔记本顶部)然后“重新连接”来解决的。
回答by Saurabh Verma
1 workaround to solve this problem is:
解决此问题的 1 种解决方法是:
Download the notebook which you are not able to save by going to: File --> Download as --> Notebook (ipynb).
Open the downloaded notebook by clicking on the downloaded file on the jupyter browser UI
通过以下方式下载无法保存的笔记本:文件 --> 下载为 --> 笔记本 (ipynb)。
通过在 jupyter 浏览器 UI 上单击下载的文件打开下载的笔记本
Now, you should be able to save (or rename) this notebook from jupyter UI
现在,您应该能够从 jupyter UI 保存(或重命名)这个笔记本
回答by liangli
This is the easiest way.
这是最简单的方法。
I did not need to open a new notebook. Instead, I reopened the tree, and reconnected the kernel. At some point I also restarted the kernel. – user650654 Oct 9 '19 at 0:17
我不需要打开一个新的笔记本。相反,我重新打开了树,并重新连接了内核。在某些时候,我还重新启动了内核。– user650654 2019 年 10 月 9 日 0:17
回答by Aakash Avinesh kumar
Open the developer setting and click console and type the following
打开开发者设置,点击控制台,输入以下内容
JSON.parse(document.getElementById('jupyter-config-data').textContent).token
JSON.parse(document.getElementById('jupyter-config-data').textContent).token
Then try saving the Notebook. The notebook that was not saving previously will save now.
然后尝试保存笔记本。以前没有保存的笔记本现在会保存。
回答by brz
I got the same problem (impossible to save either notebooks and .py modules) using an image in the nvidia docker. The solution was just opening a terminal inside jupyter without typing anything but exit once the files were saved. It was done in the same browser/jupyter instance.
我在 nvidia docker 中使用图像遇到了同样的问题(无法保存笔记本和 .py 模块)。解决方案只是在 jupyter 中打开一个终端而不输入任何内容,但在保存文件后退出。它是在同一个浏览器/jupyter 实例中完成的。
Machine OS: Ubuntu 18.04
机器操作系统:Ubuntu 18.04