我已经在flask
中编写了一个网站,它可以在调试服务器上完美运行,但是当部署在uwsgi
和nginx
的组合上时,它无法从命令行运行任何命令。例如,脚本的一个部分尝试访问它无法找到它的os.environ['HOME']
。其中一个脚本尝试运行命令行程序,但它再次抱怨无法找到它。我以我的用户身份运行nginx
,我绝对可以看到并使用所有这些内容。
我猜测uwsgi
或nginx
在'空间'那是无法看到操作系统或什么的?我怎样才能改变它或绕过它呢?
错误如下(这些是从烧瓶站点的新python线程开始的,所以这可能很重要)
环境变量的回溯:
Traceback (most recent call last):
File "/usr/lib/python2.6/site-packages/flask/app.py", line 1817, in wsgi_app
response = self.full_dispatch_request()
File "/usr/lib/python2.6/site-packages/flask/app.py", line 1477, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/usr/lib/python2.6/site-packages/flask/app.py", line 1381, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/usr/lib/python2.6/site-packages/flask/app.py", line 1475, in full_dispatch_request
rv = self.dispatch_request()
File "/usr/lib/python2.6/site-packages/flask/app.py", line 1461, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "./app/views.py", line 236, in chooseRecon
from nipypeNiftiConvert import niftiReconstruction
File "./app/nipypeNiftiConvert.py", line 5, in <module>
from nipype import logging, configNipype
File "/usr/lib/python2.6/site-packages/nipype/__init__.py", line 9, in <module>
from utils.config import NipypeConfig
File "/usr/lib/python2.6/site-packages/nipype/utils/config.py", line 21, in <module>
homedir = os.environ['HOME']
File "/usr/lib64/python2.6/UserDict.py", line 22, in __getitem__
raise KeyError(key)
KeyError: 'HOME'
第二个错误:
Traceback (most recent call last):
File "/usr/lib/python2.6/site-packages/nipype/pipeline/plugins/multiproc.py", line 18, in run_node
result['result'] = node.run(updatehash=updatehash)
File "/usr/lib/python2.6/site-packages/nipype/pipeline/engine.py", line 1386, in run
self._run_interface()
File "/usr/lib/python2.6/site-packages/nipype/pipeline/engine.py", line 1496, in _run_interface
self._result = self._run_command(execute)
File "/usr/lib/python2.6/site-packages/nipype/pipeline/engine.py", line 1622, in _run_command
result = self._interface.run()
File "/usr/lib/python2.6/site-packages/nipype/interfaces/base.py", line 946, in run
runtime = self._run_interface(runtime)
File "/usr/lib/python2.6/site-packages/nipype/interfaces/dcm2nii.py", line 50, in _run_interface
new_runtime = super(Dcm2nii, self)._run_interface(runtime)
File "/usr/lib/python2.6/site-packages/nipype/interfaces/base.py", line 1376, in _run_interface
(self.cmd.split()[0], runtime.hostname))
IOError: dcm2nii could not be found on host nu.pst.ed.ac.uk
Interface Dcm2nii failed to run.