[Python] AWS Lambda not importing Asyncio

Discussão em 'Python' iniciado por Stack, Maio 16, 2025.

  1. Stack

    Stack Membro Participativo

    So I'm working on making an application for making Reddit API calls and it seems like Lambda isn't liking how I import asyncio. I installed asyncio in a package folder using "pip install asyncio -t ." and then zipped that folder up with my project file. And I'm importing asyncio in the project file (import asyncio). However, every time I try to test my Alexa application in the Alexa Developer Console, the application won't run until I've gotten rid of the import statement.

    Here's the message I get when I try to test:


    { "errorMessage": "Syntax error in module 'reddit_alexa_py': invalid syntax (base_events.py, line 296)", "errorType": "Runtime.UserCodeSyntaxError", "stackTrace": [ " File \"/var/task/asyncio/base_events.py\" Line 296\n future = tasks.async(future, loop=self)\n" ] }
    ​

    and here's the log output:


    START RequestId: ee952162-1d06-4c04-9a0d-cfd4f0fce80f Version: $LATEST [ERROR] Runtime.UserCodeSyntaxError: Syntax error in module 'reddit_alexa_py': invalid syntax (base_events.py, line 296) Traceback (most recent call last): File "/var/task/asyncio/base_events.py" Line 296 future = tasks.async(future, loop=self)END RequestId: ee952162-1d06-4c04-9a0d-cfd4f0fce80f REPORT RequestId: ee952162-1d06-4c04-9a0d-cfd4f0fce80f Duration: 19.71 ms Billed Duration: 100 ms Memory Size: 128 MB Max Memory Used: 57 MB
    ​

    This is happening with other things I try to import, too. I think I'll need to import these packages in order to finish this project, so any help would be greatly appreciated. Thanks!

    EDIT: here's a link to the Python file https://drive.google.com/file/d/1_rbNLlwRBmt_6J0YMMa4idPSfmOKZb_j/view?usp=sharing

    Continue reading...

Compartilhe esta Página