vsajip/python-gnupg

Error migrating from python 3.7 to 3.8

jdalfons opened this issue · 8 comments

Describe the bug
I am trying to decrypt a pgp file using the python library called 'python-gnupg', I tried to decrypt the file using python 3.7 and all went well, however when I try to switch to python 3.8 the function fails stating the following.

'gpg:  WARNING:  "--secret-keyring"  is  an  obsolete  option  -  it  has  no  effect\ngpg:  no  valid  OpenPGP  data  found.
[GNUPG:]  NODATA  1
[GNUPG:]  NODATA  2
[GNUPG:]  FAILURE  decrypt  4294967295
gpg:  decrypt_message  failed:  Unknown  system  error'

To Reproduce
Steps to reproduce the behavior:
I share code to try to reproduce it, this is a part of the code I uses in 3.7 and 3.8 thats is mentioned in docs, in 3.7 it works, in 3.8 it have following error

import gnupg

gpg_binary = '/usr/local/bin/gpg'
gpg = gnupg.GPG(binary=gpg_binary)
status = gpg.decrypt_file("/user/folder/file.pgp",
                        passphrase=PASS,
                        output="/user/folder/file.csv")

Expected behavior
Expected is decript file in output destination.

Screenshots
If applicable, add screenshots to help explain your problem.

Environment

  • OS mac ventura 13.4 intel chip
  • python 3.7.16
    • python-gnupg==0.5.0
  • python 3.8.16
    • python-gnupg==0.5.0

Additional information
Add any other information about the problem here.

vsajip commented

What is your gpg version?

gpg (GnuPG) version 2.4.0

vsajip commented

Please enable logging for gnupg and see what the logs show in each case for the decryption operation.

vsajip commented

Also, can you try on a different machine? The gpg installation might be messed up on your machine (this doesn't feel like a python-gnupg error; it is tested on many Python versions, e.g. see this test run). If gpg fails, then clearly python-gnupg will also fail, as it's just a wrapper around gpg.

vsajip commented

I'll close this soon if you don't have any more feedback on this issue - I can't reproduce it.

I was able to solve it by changing the version of Python 3.9 however when reading the binary inside Lambdas from aws it fails but I think it has more to do with lambdas than with the library thank you very much.

I was able to solve it by changing the version of Python 3.9 however when reading the binary inside Lambdas from aws it fails but I think it has more to do with lambdas than with the library thank you very much.

How do you solve issue in aws lambda i got this error FileNotFoundError: [Errno 2] No such file or directory: 'gpg'[ERROR] OSError: Unable to run gpg (gpg) - it may not be available.
can you please help me

@Bhagath911 I think I checked in python tracking GPG directory and I created it if doesn't exist using os package I don't know if that can help you.