Search code examples
python-3.xgnupg

RuntimeError: GnuPG is not installed


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')

Solution

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

    pip3 install python-gnupg