问题描述
我正在Google Colab中工作,并且试图将工作目录更改为我的桌面(desktop =荷兰语中的Bureaublad,这就是为什么您在我的路径中看到'bureaublad)的原因。但是,更改工作目录始终会给我以下错误:该目录不存在。我只是复制了路径,所以一切都应该存在!在此处查看我的代码:
代码:
import os
print(os.getcwd())
os.listdir()
输出:
/content
['.config','sample_data']
代码:
os.chdir(r'C:\Users\emile\OneDrive\Bureaublad\Completed Communications Transcriptions')
输出:
---------------------------------------------------------------------------
FileNotFoundError Traceback (most recent call last)
<ipython-input-29-c4d97f3ec347> in <module>()
----> 1 os.chdir(r'C:\Users\emile\OneDrive\Bureaublad\Completed Communications Transcriptions')
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\emile\\OneDrive\\Bureaublad\\Completed Communications Transcriptions'
我做错了什么?
解决方法
您需要使用/
而不是\
import os
os.chdir('C:/')
还要检查路径是否正确,因为在您的示例中,我看到的是chdir(r'C:/')
而不是chdir('C:/')
您需要通过托管jupyter笔记本服务器连接到本地运行时,然后输入端口号,然后才能成功连接。如果您连接到托管运行时,则只能通过安装将其连接到google drive。