在Google协作中,我得到IOPub数据速率超出

Raj*_*aja 5 google-colaboratory

超出IOPub数据速率。笔记本服务器将暂时停止将输出发送到客户端,以避免崩溃。要更改此限制,请设置config变量 --NotebookApp.iopub_data_rate_limit

当前值:

NotebookApp.iopub_data_rate_limit=1000000.0 (bytes/sec)
NotebookApp.rate_limit_window=3.0 (secs)
Run Code Online (Sandbox Code Playgroud)

Sri*_*hti 12

当您尝试将大量数据打印到控制台时,通常会发生 IOPub 错误。检查您的打印语句 - 如果您尝试打印超过 10MB 的文件,则可能是这导致了错误。尝试读取文件/数据的较小部分。

我在从 Google Drive 读取文件到 Colab 时遇到了这个问题。我使用了这个链接https://colab.research.google.com/notebook#fileId=/v2/external/notebooks/io.ipynb 问题出在这段代码中

# Download the file we just uploaded.
#
# Replace the assignment below with your file ID
# to download a different file.
#
# A file ID looks like: 1uBtlaggVyWshwcyP6kEI-y_W3P8D26sz
file_id = 'target_file_id'

import io
from googleapiclient.http import MediaIoBaseDownload

request = drive_service.files().get_media(fileId=file_id)
downloaded = io.BytesIO()
downloader = MediaIoBaseDownload(downloaded, request)
done = False
while done is False:
  # _ is a placeholder for a progress object that we ignore.
  # (Our file is small, so we skip reporting progress.)
  _, done = downloader.next_chunk()

downloaded.seek(0)

#Remove this print statement
#print('Downloaded file contents are: {}'.format(downloaded.read()))
Run Code Online (Sandbox Code Playgroud)

我不得不删除最后一个打印语句,因为它超过了笔记本中的 10MB 限制 -print('Downloaded file contents are: {}'.format(downloaded.read()))
您的文件仍将被下载,您可以以较小的块读取它或读取文件的一部分。