[ERROR] AttributeError: module 'botocore.vendored.requests' has no attribute 'post' despite having import requests

See original GitHub issue

Describe the bug [ERROR] AttributeError: module 'botocore.vendored.requests' has no attribute 'post' Steps to reproduce

import requests
import json
def resume(url, headers):
    requests.post(url, data={}, headers=headers)
def scheduleResumption(api_access_token, session_id):
    headers = {
        'Authorization': f'Bearer {api_access_token}',
        'Content-Type': 'application/json',
    }
    t = Timer(interval=30.0,
          function=resume,
          args=(f'https://api.amazonalexa.com/v1/_customSkillSessions/{session_id}/resume/', headers)
          )
    t.start()

Expected behavior for it to POST Debug logs

2020-11-13T02:23:33.842-05:00	[ERROR] AttributeError: module 'botocore.vendored.requests' has no attribute 'post'
                             	Traceback (most recent call last):
                             	  File "/var/lang/lib/python3.8/imp.py", line 234, in load_module
                             	    return load_source(name, filename, file)
                             	  File "/var/lang/lib/python3.8/imp.py", line 171, in load_source
                             	    module = _load(spec)
                             	  File "<frozen importlib._bootstrap>", line 702, in _load
                             	  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
                             	  File "<frozen importlib._bootstrap_external>", line 783, in exec_module
                             	  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
                             	  File "/var/task/lambda_function.py", line 86, in <module>
                             	    requests.post(url, data = myobj)

Runtime:

tried with python 3.8 & 3.7 & have a layer that had requests library in it.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
swetashrecommented, Dec 10, 2020

@DaniyalDhz - I am using layer to add dependency to my lambda function and its working correctly. This is how i am uploading my dependency to my lambda function:

pip install requests --target python

zip -r dependency.zip python

Then create a layer using this zip file and use this layer in your lambda function. In order for the dependency to work you have to put Python dependencies into either a python directory or into python/lib/python<3.x>/site-packages.

Let us know if you are still facing any issues.

1reaction
nateprewittcommented, Nov 13, 2020

Hi @DaniyalDhz,

Requests was removed from botocore a little over a year ago in version Botocore 1.13.0. We released a blog post on October 1, 2019 which has full details on the change. Going forward, you’ll want to install requests separately with pip install requests.

Read more comments on GitHub >

github_iconTop Results From Across the Web

module 'botocore.vendored.requests' has no attribute 'Post ...
But I am not sure if I need to import certain things from Python. It fails when I'm about to post the message....
Read more >
Don't Import requests From botocore.vendored
Importing from botocore.vendored is an anti-pattern in general, ... AttributeError: module 'botocore.vendored.requests' has no attribute ...
Read more >
module 'botocore.vendored.requests' has no attribute エラー ...
[ERROR] AttributeError: module 'botocore.vendored.requests' has no attribute 'get' Traceback (most recent call last): File ...
Read more >
Removing the vendored version of requests from Botocore
Starting 10/21/19, we will be removing the vendored version of the requests library in Botocore. In this post, we'll cover the key details....
Read more >
AWS Blog - How to send yourself a daily inspirational quote ...
You will notice an error - "errorMessage": "module 'botocore.vendored.requests' has no attribute 'request'". For those new to coding, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found