0

I am currently trying to decrypt a .gpg file in python using the package python-gnupg.

However, when I run my script:

file = input.xml.gpg

gpg = gnupg.GPG()

with open(file, 'rb') as f:
    status = gpg.decrypt_file(f, passphrase='***********', output='output.xml')

print(status.ok)
print(status.status)
print(status.stderr)

I come across this error:

Traceback (most recent call last):
  File "C:\Users\D.Nahmias\Project\venv\lib\site-packages\gnupg.py", line 941, in __init__
    p = self._open_subprocess(['--version'])
  File "C:\Users\D.Nahmias\Project\venv\lib\site-packages\gnupg.py", line 1007, in _open_subprocess
    result = Popen(cmd, shell=False, stdin=PIPE, stdout=PIPE, stderr=PIPE, startupinfo=si, env=self.env)
  File "C:\Users\D.Nahmias\AppData\Local\Programs\Python\Python39\lib\subprocess.py", line 951, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "C:\Users\D.Nahmias\AppData\Local\Programs\Python\Python39\lib\subprocess.py", line 1420, in _execute_child
    hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] The system cannot find the file specified

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\D.Nahmias\Project\decryption.py", line 35, in <module>
    main()
  File "C:\Users\D.Nahmias\Project\decryption.py", line 19, in main
    gpg = gnupg.GPG()
  File "C:\Users\D.Nahmias\Project\venv\lib\site-packages\gnupg.py", line 945, in __init__
    raise OSError(msg)
OSError: Unable to run gpg (gpg) - it may not be available.

I tried multiple solution that I found on the web, I installed gpg4win and gnupg from the official website but it still didn't work.

If somebody could give me a hint, I would really appreciate it.

Thanks.

0 Answers0