简体   繁体   English

在 Jupyter 笔记本配置文件中更改数据速率

[英]change data rate in Jupyter notebook config file

Today, while running a Python script in Jupyter Notebook launched from Anaconda Navigator, the run was aborted and I received an alert stating " IOPub data rate exceeded ".今天,在从 Anaconda Navigator 启动的 Jupyter Notebook 中运行 Python 脚本时,运行被中止,我收到一条警告,指出“ IOPub 数据速率超出”。 I tried to implement some of the solutions given here and elsewhere on SO, but have run into various issues:我尝试在 SO 上实施此处和其他地方给出的一些解决方案,但遇到了各种问题:

1) One suggestion is to create a <jupyter_notebook_config.py> file through the command line: 1)一个建议是通过命令行创建一个 <jupyter_notebook_config.py> 文件:

$ jupyter notebook --generate-config

This creates the file in <C:\Users\msfea.jupyter>.这将在 <C:\Users\msfea.jupyter> 中创建文件。 I am then supposed to comment out the existing然后我应该注释掉现有的

c.NotebookApp.iopub_data_rate_limit = 1000000

and replace it with并将其替换为

c.NotebookApp.iopub_data_rate_limit = 10000000

The problem is that when I open the file (in Thonny), the entire script of ~1300 lines is already commented out.问题是当我打开文件(在 Thonny 中)时,大约 1300 行的整个脚本已经被注释掉了。 Uncommenting everything doesn't work, and practically I can't go through it line by line.取消注释所有内容都不起作用,实际上我无法逐行浏览。 I just cannot figure out what the starting appearance of the script should be, much less modify it.我只是无法弄清楚脚本的初始外观应该是什么,更不用说修改它了。

2) Another suggestion is to run 2)另一个建议是运行

jupyter notebook --NotebookApp.iopub_data_rate_limit=1.0e10

from Anaconda Navigator's command line.来自 Anaconda Navigator 的命令行。 This automatically opens a new instance of Jupyter Notebook in my browser and if I run my script in this new instance of Jupyter, it works!这会自动在我的浏览器中打开一个新的 Jupyter Notebook 实例,如果我在这个新的 Jupyter 实例中运行我的脚本,它就可以工作! Problem is, it's not permanent.问题是,它不是永久性的。 If I close everything down and then relaunch Anaconda Navigator and Jupyter Notebook, my script once again fails with the same error message, "IOPub data rate exceeded".如果我关闭所有内容,然后重新启动 Anaconda Navigator 和 Jupyter Notebook,我的脚本将再次失败,并显示相同的错误消息“超出 IOPub 数据速率”。 While I suppose I could live with this, it's really not ideal and should be surmountable.虽然我想我可以忍受这个,但它真的不理想,应该是可以克服的。 If only I knew how!要是我知道怎么做就好了!

Thanks for your help.谢谢你的帮助。

OK, I figured it out based on a different understanding of what was meant here .好的,我是根据对此处含义的不同理解而弄清楚的。 Note, I am using a PC running Windows 11. For anyone interested, follow these steps.请注意,我使用的是运行 Windows 11 的 PC。任何有兴趣的人,请按照以下步骤操作。 Just to make clear, I use the version of Jupyter Notebook launched from within Anaconda Navigator .为了清楚起见,我使用从Anaconda Navigator中启动的Jupyter Notebook版本。 I cannot be certain that the steps below would work on other platforms.我不能确定以下步骤是否适用于其他平台。

  1. At the command line (I launched the terminal from within Anaconda Navigator -- no idea whether that's important), type or paste the following text: jupyter notebook --generate-config在命令行(我从Anaconda Navigator中启动终端——不知道这是否重要),输入或粘贴以下文本: jupyter notebook --generate-config

This creates the python file jupyter_notebook_config.py in the .jupyter folder found here: C:\Users\your_handle\.jupyter这将在此处找到的.jupyter文件夹中创建 python 文件jupyter_notebook_config.py:C:\Users\your_handle\.jupyter

  1. Open the file in an IDE (I used Thonny).在 IDE 中打开文件(我使用的是 Thonny)。 You will see that the entirety of the script is commented out (meaning there is a # before every line).您会看到整个脚本都被注释掉了(意味着每一行之前都有一个#)。 Use the "Find" function to search for this text: c.NotebookApp.iopub_data_rate_limit = 1000000使用“查找”功能搜索此文本: c.NotebookApp.iopub_data_rate_limit = 1000000

  2. Uncomment this line by deleting the # that starts the line.通过删除开始该行的 # 取消注释该行。 It will change from greyed out to typical text.它将从灰色变为典型文本。

  3. Add one zero to the end of the value 1000000, thereby increase the data rate limit from one million to ten million bytes/sec.在值 1000000 的末尾添加一个零,从而将数据速率限制从一百万字节/秒增加到一千万字节/秒。 (No idea whether one could or should go higher. I have seen warnings about setting the data rate limit too high.) (不知道是否可以或应该更高。我已经看到有关将数据速率限制设置得太高的警告。)

  4. Save.节省。

  5. I then closed all programs/applications, shut down the pc and then re-started.然后我关闭了所有程序/应用程序,关闭了电脑,然后重新启动。 No idea whether this was necessary.不知道这是否有必要。

Hope this helps someone.希望这可以帮助某人。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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