python-gnupg 0.4.1 and pathlib

Skip to first unread message

Maurice Kemmann

Feb 5, 2018, 4:51:35 PM2/5/18
to python-gnupg

i am a Python newbie and playing around with python-gupg. Working on Linux and Windows 10 i use pathlib for os independent work with paths. My problem, python-gnupg seems not to work properly with pathlib (or it is my fault?):

import gnupg
from pathlib import Path
gpg = gnupg.GPG(gnupghome = Path("/Users/mucki/Cert/"))

 With this code i get the follwing error:

 python.exe .\

Traceback (most recent call last):
  File ".\", line 3, in <module>
    gpg = gnupg.GPG(gnupghome = Path("/Users/mucki/Cert/"))
  File "C:\Users\mucki\AppData\Local\Programs\Python\Python36\lib\site-packages\", line 755, in __init__
    p = self._open_subprocess(["--version"])
  File "C:\Users\mucki\AppData\Local\Programs\Python\Python36\lib\site-packages\", line 831, in _open_subprocess
  File "C:\Users\mucki\AppData\Local\Programs\Python\Python36\lib\", line 707, in __init__
    restore_signals, start_new_session)
  File "C:\Users\mucki\AppData\Local\Programs\Python\Python36\lib\", line 964, in _execute_child
    args = list2cmdline(args)
  File "C:\Users\mucki\AppData\Local\Programs\Python\Python36\lib\", line 461, in list2cmdline
    needquote = (" " in arg) or ("\t" in arg) or not arg
TypeError: argument of type 'WindowsPath' is not iterable

Could you give me a hint?

By the way, hard coding the path with Windows specific backslashes ( \\Users\\mucki\\Cert\\ ) works of course.

Thanks in advance,


Vinay Sajip

Feb 5, 2018, 4:57:25 PM2/5/18
to python-gnupg
You will see that the error occurs in the Python standard library - in the standard library subprocess module. I don't think you can pass in path instances. I don't believe your problem is related to python-gnupg. Try a test case with just subprocess and see how you get on. Ask for help on the python-list mailing list.


Vinay Sajip
Reply all
Reply to author
0 new messages