5

Requirement: To run python decryption of the file

I have installed gnupg in the virtual env in MacOS, also import gnupg works fine but the second line is throwing an error as below

>>> gpg = gnupg.GPG() Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/Users/.local/share/virtualenvs/mypython-sPLN-T2A/lib/python3.8/site-packages/gnupg/gnupg.py", line 117, in __init__ super(GPG, self).__init__( File "/Users/.local/share/virtualenvs/mypython-sPLN-T2A/lib/python3.8/site-packages/gnupg/_meta.py", line 182, in __init__ self.binary = _util._find_binary(binary) File "/Users/.local/share/virtualenvs/mypython-sPLN-T2A/lib/python3.8/site-packages/gnupg/_util.py", line 429, in _find_binary raise RuntimeError("GnuPG is not installed!") RuntimeError: GnuPG is not installed!

code

import gnupg
gpg = gnupg.GPG()

SOLUTION:

I was finally able to resolve it,

  1. Installing brew install GnuPG
  2. import gnupg gpg = gnupg.GPG('/usr/local/bin/gpg')
Karthik
  • 441
  • 5
  • 17

2 Answers2

1

I installed a fresh new Python version (3.10.0) and python-gnupg, and it started working:

pip3 install python-gnupg
DavidS
  • 2,160
  • 1
  • 19
  • 22
0

Install gnupg package

pip install python-gnupg

Then explicitly specify the path of gpg binary during object initialization.

gpg_binary = '/usr/local/bin/gpg'
gpg = gnupg.GPG(binary=gpg_binary)
Super Kai - Kazuya Ito
  • 22,221
  • 10
  • 124
  • 129
rboyapat
  • 1
  • 2