0

I'm trying to import ServiceAccountCredentials from oauth2client.service_account in my AWS-Lambda code but it keeps on giving me the error Invalid Syntax.

I run the normal code in my own PC and the code works, but when I move the code into my AWS-Lambda, it gives me the Invalid Syntax error. I already added all the libraries needed into my AWS Lambda layer.

from oauth2client.service_account import ServiceAccountCredentials

it gives an error :

START RequestId: 42276808-a49f-45ea-a955-b19206197c87 Version: $LATEST
Syntax error in module 'handler': invalid syntax (__init__.py, line 475)

END RequestId: 42276808-a49f-45ea-a955-b19206197c87
REPORT RequestId: 42276808-a49f-45ea-a955-b19206197c87  Duration: 0.33 ms   Billed Duration: 100 ms     Memory Size: 1024 MB    Max Memory Used: 54 MB

Even if I am only importing the library it gives me an error. Is there another way I can import or use ServiceAccountCredentials?

kbr85
  • 1,416
  • 12
  • 27

1 Answers1

0

Turns out I use the wrong Python version runtime in my aws-lambda haha. I used Python 2.7 but it should've been Python 3.6.