由于某种原因,我无法导入 office365.sharepoint.file

For some reason I'm unable to import office365.sharepoint.file

我正在尝试导入 office365.sharepoint.file,但我一直收到错误

ModuleNotFoundError: 没有名为 'office365.sharepoint.file'

的模块

我卡住了,因为我一直无法查明用于导入它的方法是否已更改。

如有任何帮助,我们将不胜感激

import io
from office365.sharepoint.file import File 

response = File.open_binary(ctx, relative_url)

#save data to BytesIO stream
bytes_file_obj = io.BytesIO()
bytes_file_obj.write(response.content)
bytes_file_obj.seek(0) #set file object to start

#read file into pandas dataframe
df = pd.read_excel(bytes_file_obj)```


---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-9-ce2948d5390a> in <module>
      1 import pandas as pd
      2 import io
----> 3 from office365.sharepoint.file import File
      4 
      5 response = File.open_binary(ctx, relative_url)

ModuleNotFoundError: No module named 'office365.sharepoint.file'```

尝试安装 o365 库。它会解决你的问题。

我发现必须将完整的 URL 路径指向文件,而不仅仅是路径:

from office365.sharepoint.files.file import File