I need to make a rest call in a python script that runs once a day. I cannot pack the "requests" package into my python package using AWS Lambdas. I get an error: "Unable to import module" lambda_function ": no module named lambda_function"
I broke it into a predefined hello_world script. I can pack it into a ZIP file and download it. Everything works. As soon as I put the “import requests” into the file, I get this error.
Here is what I have already done:
- The zip permissions and project folders (including subfolders) are set to `chmod 777`. Therefore, permissions should not be a problem.
- The script itself is in the root folder. When you open a zip file, you directly see it.
- I installed the request package in the root folder of the project using `sudo pip install requests -t PATH_TO_ROOT_FOLDER`
The naming of everything looks like this:
- zip file: lambda_function.zip
- py file: lambda_function.py
- handler method: lambda_handler (event, context)
- handler definition in "webconfig: lambda_function.lambda_handler
The file I want to run at the end is as follows:
import requests import json def lambda_handler(event, context): url = 'xxx.elasticbeanstalk.com/users/login' headers = {"content-type": "application/json", "Authorization": "Basic Zxxxxxxxxx3NjxxZxxxxzcw==" } response = requests.put(url, headers=headers, verify=False) return 'hello lambda_handler'
I am happy for ANY help. I have already used several hours on this issue.
codepleb
source share