2
저는 python-gnupg로 플라스크 응용 프로그램에서 gpg를 인터페이싱하고 있습니다. 모듈은 나머지 응용 프로그램과 함께 virtualenv에 설치됩니다. 실행할 때 나는 500 내부 서버 오류가 발생하고 예외입니다 :플라스크 응용 프로그램에서 gpg를 찾을 수 없습니다
File "./myproject/views/settings.py", line 257, in settings_keys_add
gpg = gnupg.GPG()
File "/home/puse/myproject/myproject/lib/python3.5/site-packages/gnupg.py", line 733, in __init__
p = self._open_subprocess(["--version"])
File "/home/puse/myproject/myproject/lib/python3.5/site-packages/gnupg.py", line 786, in _open_subprocess
startupinfo=si)
File "/usr/lib/python3.5/subprocess.py", line 947, in __init__
restore_signals, start_new_session)
File "/usr/lib/python3.5/subprocess.py", line 1551, in _execute_child
raise child_exception_type(errno_num, err_msg)
FileNotFoundError: [Errno 2] No such file or directory: 'gpg'
GPG가 설치되어 있고 작동 :
[email protected] ~/puse> which gpg
/usr/bin/gpg
[email protected] ~/puse> gpg --gen-key
gpg (GnuPG) 1.4.20; Copyright (C) 2015 Free Software Foundation, Inc.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Please select what kind of key you want:
(1) RSA and RSA (default)
(2) DSA and Elgamal
(3) DSA (sign only)
(4) RSA (sign only)
Your selection?
gpg: Interrupt caught ... exiting
나는 또한 VIRTUALENV 내 파이썬에서 작동하도록 얻을 수 있습니다 :
Python 3.5.2 (default, Jul 5 2016, 12:43:10)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import gnupg
>>> gpg = gnupg.GPG()
>>> a = gpg.scan_keys("/opt/keys/2a798434-ebb3-4dc6-9f76-fd46f0cce6fa")
나는 그것이 응용 프로그램이 실행중인 사용자와 관련이 있다고 생각하지만 응용 프로그램은 내 사용자로 실행되지만 그룹은 www-data로 설정되어 있습니다. 나는 ps를 실행하여 이것을 확인했다.
시스템 응용 프로그램의 .service 파일 이 라인 (에 추가되지 않음) PATH 변수를 무시
[Unit]
Description=uWSGI instance to serve myproject
After=network.target
[Service]
User=puse
Group=www-data
WorkingDirectory=/home/path
Environment="PATH=/home/path"
ExecStart=/home/path/uwsgi --ini config.ini
[Install]
WantedBy=multi-user.target