vsajip/python-gnupg

Not able to run python-gnupg without installing gnupg package in AWS Lambda

kp-orion opened this issue · 3 comments

Describe the bug
Trying to run python-gnupg==0.4.6 and up with AWS Lambda using python 3.8 and up but getting OSError: Unable to run gpg (gpg) - it may not be available.
To Reproduce
Steps to reproduce the behavior:

  1. get the python-gnupg package
  2. copy gnupg.py
    .
    ├── gnupg.py
    ├── lambda_function.py

lambda_function.py

import tempfile
import json

def lambda_handler(event, context):
    # TODO implement
    gpg_home = tempfile.mkdtemp()
    gpg = gnupg.GPG(gnupghome=gpg_home)
    return {
        'statusCode': 200,
        'body': json.dumps('just Make it work')
    }
  1. Getting Error
    OSError: Unable to run gpg (gpg) - it may not be available.

Expected behavior
I was able to run the python-gnupg with python3.7.

I don't think this is a python-gnupg problem. If the gpg executable is not available, python-gnupg can't work. The presence or absence of the gpg executable is unconnected to the Python version - they are completely independent of each other. I would check your AWS configuration. Is your 3.7 deployment exactly the same other than Python version?

@vsajip Yes, Exactly same just two different python runtime.

Change your lambda function to output where gpg is. If it can't be found, that's the cause of your problem, and you need to ensure it's there.