aws lambda Unable to import module 'lambda_function': No module named 'requests'

后端 未结 4 1042
北恋
北恋 2020-12-28 17:50

I have recently started to use AWS Lambda to use triggers against some python code I have written. I currently have 2 lambda functions, both of which have been created with

4条回答
  •  独厮守ぢ
    2020-12-28 18:41

    Give it a check to this answer

    If you're working with Python on AWS Lambda, and need to use requests, you better use urllib3, it is currently supported on AWS Lambda and you can import it directly, check the example on urllib3 site.

    import urllib3
    
    http = urllib3.PoolManager()
    r = http.request('GET', 'http://httpbin.org/robots.txt')
    
    r.data
    # b'User-agent: *\nDisallow: /deny\n'
    r.status
    # 200
    

提交回复
热议问题