FileNotFoundError:[Errno 2] 没有这样的文件或目录 [在 google colab 中从我的计算机打开电子表格]

FileNotFoundError: [Errno 2] No such file or directory [opening spreadsheets from my computer in google colab]

提问人:oceanpath 提问时间:5/27/2022 更新时间:5/27/2022 访问量:1767

问:

我正在尝试在 google colab 中从我的计算机打开电子表格,此错误正在返回。

/usr/local/lib/python3.7/dist-packages/pandas/io/common.py in get_handle(path_or_buf, mode, encoding, compressio
n, memory_map, is_text, errors, storage_options)
    709         else:
    710             # Binary mode
--> 711             handle = open(handle, ioargs.mode)
    712         handles.append(handle)
    713 

FileNotFoundError: [Errno 2] No such file or directory:

电子表格是否必须位于特定目录中? 它可以在我的桌面上吗?我应该如何复制其地址?

蟒蛇 谷歌-colab

评论

0赞 besjon_c 5/27/2022
您无法从计算机打开文件。请将其上传到 colab 或您的驱动器中。如果您将其上传到您的驱动器中,则可以将驱动器与 colab 连接并访问电子表格。要上传,您只需拖放到 colab 中的内容文件夹中即可。(Files)
0赞 Thornily 5/27/2022
确保你给出的路径是正确的,并提供你尝试过的东西。
0赞 besjon_c 5/27/2022
您也可以使用从您的设备手动上传 colab 中的文件。只需执行一个单元格from google.colab import files dataset_file_dict = files.upload()
0赞 besjon_c 5/27/2022
访问您上传的文件test_file = open('/content/your_file.txt', "r")
0赞 besjon_c 5/27/2022
要连接您的Google云端硬盘: 然后从驱动器访问一个文件:from google.colab import drive drive.mount('/content/gdrive')text_file = "/content/gdrive/MyDrive/folderName/your-file.txt"

答:

0赞 oceanpath 5/27/2022 #1

解决!!

我试过了

drive.mount('/content/gdrive')

from google.colab import files
dataset_file_dict = files.upload()

然后出现了一个“搜索”窗口,所以我可以直接在桌面上搜索我的文件。

非常感谢!