Python FileNotFoundError:[Errno 2]文件b';smallsample.csv';不存在:b';smallsample.csv';
在Google Colab中,我安装了Google drive:Python FileNotFoundError:[Errno 2]文件b';smallsample.csv';不存在:b';smallsample.csv';,python,google-colaboratory,Python,Google Colaboratory,在Google Colab中,我安装了Google drive: from google.colab import drive #Mounted at gdrive(set directory) drive.mount("/content/gdrive") 并设置我的路径以读取名为smallsample.csv的文件: path ='gdrive/My Drive' #/data_analysis/datafiles/reports df= pd.read_csv('smallsamp
from google.colab import drive #Mounted at gdrive(set directory)
drive.mount("/content/gdrive")
并设置我的路径以读取名为smallsample.csv的文件:
path ='gdrive/My Drive' #/data_analysis/datafiles/reports
df= pd.read_csv('smallsample.csv', sep=',')
然而,它回来了
FileNotFoundError: [Errno 2] File b'smallsample.csv' does not exist: b'smallsample.csv'
如果我将r
添加到df=pd.read\u csv('smallsample.csv',sep=',')
,则没有任何帮助。我也尝试了其他帖子建议的一些方法,但都没有解决这个问题。有人能帮忙吗?干杯。分配路径=…
不会更改当前工作目录。相反,请使用Michael建议的绝对路径,或使用以下方法更改工作目录:
%cd/content/gdrive/My-Drive
您可以使用%pwd
查看当前工作目录,并使用%ls
尝试绝对路径/content/gdrive/../smallsample.csv
查看当前目录中的文件。嗨,Michael,它工作了。谢谢:)嗨,鲍勃,谢谢你的回答。path='gdrive/My Drive'
是否在此处执行任何操作?不,没有必要执行path=…
分配,并且不会对您共享的代码段产生任何影响。