microsoftarchive/msgraph-sdk-python

ImportError: cannot import name drive_item_collection

cnbeining opened this issue · 13 comments

import msgraph
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/msgraph/__init__.py", line 96, in <module>
    from .request.directory_object_request_builder import DirectoryObjectRequestBuilder
  File "/usr/local/lib/python2.7/dist-packages/msgraph/request/directory_object_request_builder.py", line 11, in <module>
    from ..request.directory_object_check_member_groups import DirectoryObjectCheckMemberGroupsRequestBuilder
  File "/usr/local/lib/python2.7/dist-packages/msgraph/request/directory_object_check_member_groups.py", line 12, in <module>
    from ..request import drive_item_collection 
  File "/usr/local/lib/python2.7/dist-packages/msgraph/request/drive_item_collection.py", line 11, in <module>
    from ..request import drive_item_request_builder # import DriveItemRequestBuilder
  File "/usr/local/lib/python2.7/dist-packages/msgraph/request/drive_item_request_builder.py", line 12, in <module>
    from ..request.drive_item_search import DriveItemSearchRequestBuilder
  File "/usr/local/lib/python2.7/dist-packages/msgraph/request/drive_item_search.py", line 13, in <module>
    from ..request import drive_item_collection 
ImportError: cannot import name drive_item_collection

Are there some import loops?

I get the same error. Does anyone know a solution?

Thanks for reporting this. We are working on a fix for this.

had the same problem.
To fix this you have to comment out the import line in the libraries where the error occurred.
in this case in
/usr/local/lib/python2.7/dist-packages/msgraph/request/drive_item_search.py
line 14
# from ..request import drive_item_collection

But there are more files with the same issue to fix :-(

@AlfredoCubitos Hey, I forked this library to help the Microsoft team a bit. I can't look into this right now, but if you have a clue as to what this should be instead of the wrong import I might fix and do a pull request for them

Even I am getting this error. Seems like folks at microsoft have no love for python.

I am also getting the same error. Is there any update regarding this error?

Hi Team,

It looks like the issue still there on python 2.7. May I know any plan to fix it? Thanks.

This is still in the backlog, but hasn't been updated yet. We'll post back when we begin work on this.

I encountered exact same problem in running Python2. Upgraded to Python3 and everything works perfectly.

It looks to me like a circular import, when you import drive_item_collection it goes for the drive_item_request_builder who goes for drive_item_search who then tries with drive_item_collection.

msgraph/request/drive_item_collection.py in <module>()
      9 from ..collection_base import CollectionRequestBase, CollectionResponseBase, CollectionPageBase
     10 from ..request_builder_base import RequestBuilderBase
---> 11 from ..request import drive_item_request_builder # import DriveItemRequestBuilder
     12 #from .drive_item_request_builder import DriveItemRequestBuilder
     13 from ..model.drive_item import DriveItem

msgraph/request/drive_item_request_builder.py in <module>()
     10 from ..request_builder_base import RequestBuilderBase
     11 from ..request.drive_item_create_link import DriveItemCreateLinkRequestBuilder
---> 12 from ..request.drive_item_search import DriveItemSearchRequestBuilder
     13 from ..request.drive_item_content_request import DriveItemContentRequestBuilder
     14 from ..request import user_request_builder

msgraph/request/drive_item_search.py in <module>()
     11 from ..options import *
     12 import json
---> 13 from ..request import drive_item_collection
     14
     15

ImportError: cannot import name drive_item_collection

Can you guys address this? Was opened 9 months ago. Although it works fine in python3, it's probably still happening.

nnkps commented

Looks like there are circular imports that need to be fixed, please could someone address this? Python2.7 integration with OneDrive for Business is a pain now.

Closing as we are archiving this project