iopipe-python icon indicating copy to clipboard operation
iopipe-python copied to clipboard

Usage example not working on AWS Python 3.6

Open XerTheSquirrel opened this issue 7 years ago • 12 comments

Description

Following the README, the minimalist sample does not seem to work at all on Python 3.6. The README does say "This package supports Python 2.7 and 3.6, the runtimes supported by AWS Lambda.".

Steps to reproduce the issue:

  1. Setup new Lambda.
  2. Choose Python 3.6
  3. Follow https://github.com/iopipe/iopipe-python#installation
  4. Follow https://github.com/iopipe/iopipe-python#usage
  5. Create index.py
  6. Place as contents:
from iopipe import IOpipe
iopipe = IOpipe('token')

@iopipe
def lambda_handler(event, context):
    pass
  1. Set entry point to: index.lambda_handler
  2. Save it
  3. Test it with anything

Describe the results you received:

Response:
{
  "errorMessage": "Syntax error in module 'index'"
}

Request ID:
"102bedeb-86bf-11e8-8562-97ea3fe2926e"

Function Logs:
START RequestId: 102bedeb-86bf-11e8-8562-97ea3fe2926e Version: $LATEST
Syntax error in module 'index': invalid syntax (_base.py, line 414)

END RequestId: 102bedeb-86bf-11e8-8562-97ea3fe2926e
REPORT RequestId: 102bedeb-86bf-11e8-8562-97ea3fe2926e	Duration: 0.83 ms	Billed Duration: 100 ms 	Memory Size: 128 MB	Max Memory Used: 22 MB	

Describe the results you expected:

Expected the lambda to pass.

Additional information you deem important (e.g. issue happens only occasionally):

Switching to Python 2.7 works.

XerTheSquirrel avatar Jul 13 '18 17:07 XerTheSquirrel

@XerTheSquirrel This line:

Syntax error in module 'index': invalid syntax (_base.py, line 414)

Appears to be referencing AWS Lambda's own bootstrap system. There is no _base.py in the iopipe module.

kolanos avatar Sep 25 '18 17:09 kolanos

Closing as unable to reproduce.

kolanos avatar May 15 '19 18:05 kolanos

I'm also having this problem with my application. It was running stable on production for almost a year and suddenly, in a new deploy, it started to throw this error.

mateusfccp avatar Jul 04 '19 19:07 mateusfccp

I am seeing the issue as well.

pramodsetlur avatar Jul 19 '19 00:07 pramodsetlur

@pramodsetlur, @mateusfccp Any details to help reproduce? Are you both getting the same traceback? Is this with Serverless or something else?

kolanos avatar Jul 19 '19 15:07 kolanos

@pramodsetlur, @mateusfccp Is the futures package installed? IOpipe installs a futures package on python2.7 which is a backport of concurrent.futures which is only available in python3.x. However, if you are running python2.7 locally and install IOpipe and then deploy to python3.6 the futures package will be included which may result in this error. Solution is to ensure that futures is not included in your python3.6 deployment.

kolanos avatar Jul 19 '19 15:07 kolanos

@kolanos Apologies; I am not using iopipie; My error is more related just to Lambda. I am deploying with serverless. It runs successfully with 3.7 on local and crashes with the same error Syntax error in module 'index': invalid syntax (_base.py, line 414) on Lambda 3.6. I changed it to 2.7 and it worked fine. (So, my message might not be relevant to iopipe at all.)

pramodsetlur avatar Jul 19 '19 20:07 pramodsetlur

@pramodsetlur I traced the invalid syntax (_base.py, line 414) back to the futures backport. So it is possible you're still running into that issue even without IOpipe being present.

kolanos avatar Jul 23 '19 19:07 kolanos

@pramodsetlur If you're willing to give IOpipe another try, we have a new layers plugin for Serverless that doesn't require a code change: https://github.com/iopipe/serverless-iopipe-layers

kolanos avatar Jul 23 '19 19:07 kolanos

@kolanos I only commented on this issue because i was seeing the particular error in _base.py. Was never using iopipie. But appreciate the responses.

pramodsetlur avatar Jul 23 '19 23:07 pramodsetlur

The fix for this is to change either

  1. Use pip3 install for lambda runtimes of 3.X
  2. Delete the folder in your packaged concurrent/futures/

jonahjon avatar Aug 18 '19 18:08 jonahjon

Going to add this to a troubleshooting section in the README.

kolanos avatar Aug 19 '19 15:08 kolanos