Office365-REST-Python-Client icon indicating copy to clipboard operation
Office365-REST-Python-Client copied to clipboard

SyntaxError with Python 3.6 using SharePoint

Open SebastianLeitz opened this issue 1 year ago • 1 comments

I am trying to use this module inside an Ansible inventory script to retrieve hosts from a SharePoint list. This works well in a recent (3.11) Python version, but unfortunately I need to rely on Python 3.6 in another environment. There the script fails right away in line 1:

from office365.sharepoint.client_context import ClientContext

# [...] Authentication code like in this example: https://github.com/vgrem/Office365-REST-Python-Client/blob/master/examples/sharepoint/connect_with_client_certificate.py

The SyntaxError thrown is this:

Traceback (most recent call last):
  File "inventory-from-spo.py", line 1, in <module>
    from office365.sharepoint.client_context import ClientContext
  File "/home/me/.local/lib/python3.6/site-packages/office365/sharepoint/client_context.py", line 16, in <module>
    from office365.runtime.odata.request import ODataRequest
  File "/home/me/.local/lib/python3.6/site-packages/office365/runtime/odata/request.py", line 6, in <module>
    from office365.runtime.client_object import ClientObject
  File "/home/me/.local/lib/python3.6/site-packages/office365/runtime/client_object.py", line 1
    from __future__ import annotations
    ^
SyntaxError: future feature annotations is not defined

Is there some kind of compatibility layer one needs to activate?

SebastianLeitz avatar Feb 19 '24 09:02 SebastianLeitz

I also had this dependency error, I had to uninstall the current version and reinstall with this version that is specified as support for the python version.

https://pypi.org/project/Office365-REST-Python-Client/2.1.8/

image

image

Hope this helps (:

MaykJD avatar Apr 25 '24 13:04 MaykJD