vsajip/python-gnupg

Unable to run gpg (./gpg) - it may not be available.

vidhyavidhu1954 opened this issue · 4 comments

Describe the bug
I am using python 3.11 version in my aws lambda. Python-gnupg version i have used 0.5.2 but it is not working . i am facing issue like
FileNotFoundError: [Errno 2] No such file or directory: './gpg' . Even i was trying to add it as additional layer in lambda but it is not working as well .
To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior
without any fail , gnupg version might works for my python lambda

Screenshots
image

Environment

  • OS, including version
  • Version of this library

Additional information
Attached the cloudwatch aws log event for reference

Unable to run gpg (./gpg) - it may not be available. --   | 2024-03-13T19:21:38.177+05:30 | Traceback (most recent call last):   | 2024-03-13T19:21:38.177+05:30 | File "/var/task/lambda_function.py", line 67, in lambda_handler   | 2024-03-13T19:21:38.177+05:30 | if validate_file(event_dictionary, downloaded_file_path, log):   | 2024-03-13T19:21:38.177+05:30 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | 2024-03-13T19:21:38.177+05:30 | File "/opt/python/lib/python3.11/site-packages/gnupg.py", line 1094, in __init__   | 2024-03-13T19:21:38.177+05:30 | p = self._open_subprocess(['--list-config', '--with-colons'])   | 2024-03-13T19:21:38.177+05:30 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^   | 2024-03-13T19:21:38.177+05:30 | File "/opt/python/lib/python3.11/site-packages/gnupg.py", line 1164, in _open_subprocess   | 2024-03-13T19:21:38.177+05:30 | result = Popen(cmd, shell=False, stdin=PIPE, stdout=PIPE, stderr=PIPE, startupinfo=si,   | 2024-03-13T19:21:38.177+05:30 | File "/var/lang/lib/python3.11/subprocess.py", line 1026, in __init__   | 2024-03-13T19:21:38.177+05:30 | self._execute_child(args, executable, preexec_fn, close_fds,   | 2024-03-13T19:21:38.177+05:30 | File "/var/lang/lib/python3.11/subprocess.py", line 1950, in _execute_child   | 2024-03-13T19:21:38.177+05:30 | raise child_exception_type(errno_num, err_msg, err_filename)   | 2024-03-13T19:21:38.177+05:30 | FileNotFoundError: [Errno 2] No such file or directory: './gpg'   | 2024-03-13T19:21:38.177+05:30 | [ERROR] OSError: Unable to run gpg (./gpg) - it may not be available. Traceback (most recent call last):   File "/var/task/lambda_function.py", line 78, in lambda_handler     move_error_file(event_dictionary, downloaded_file_path, log)   File "/var/task/file_reader_helper.py", line 196, in encrypt_data_file     gpg = gnupg.GPG(gnupghome=LAMBDA_TMP_PATH, gpgbinary='./gpg')   File "/opt/python/lib/python3.11/site-packages/gnupg.py", line 1098, in __init__     raise OSError(msg)

This is not a bug in python-gnupg - it is to do with a combination of the setup of your AWS Lambda environment, where you have told python-gnupg to find the gpg executable, and perhaps what the current directory is.

Hi @vsajip
Is there any example to use this jar with 3.11 ? Can you please provide us ?

In 3.7 we used to give this in requirements.txt .

Is there any example to use this jar

Which jar? I think you may need help from someone with a deeper understanding of the environment you're working with.