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

Viewed 4262

I'm trying to import office365.sharepoint.file and I keep getting the error

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

I'm stuck because I haven't been able to find out whether the method used to import it has changed.

Any help would be appreciated

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'```
2 Answers

I found that one has to path the full URL to File, not just the path:

from office365.sharepoint.files.file import File

Try to install the o365 library. It would solve your problem.

Related