2016-08-22 17 views
2

私はpython-gnupgを使ってフラスコのアプリケーションでgpgをインタフェースしています。モジュールは他のアプリケーションと一緒にvirtualenvにインストールされます。実行しているとき、私は500内部サーバーエラーが表示され、例外がある:GPGがインストールされ、動作してフラスコのアプリケーションが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' 

[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から仕事を得ることができます。

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 

答えて

1

Environment="PATH=/home/path" 

変更それ

Environment="PATH=/home/path:/usr/bin:/bin" 

には、標準のコマンドを使用することができるようにします。

Environment="PATH=/usr/bin:/bin" 
:/ホーム/パスが存在する場合

はところで、私はちょうど設定し、その場合には、いないと仮定し、確認してください

関連する問題