在Python graphviz中调用graph.layout时出现IOError异常

时间:2015-01-12 14:50:44

标签: python mod-wsgi wsgi graphviz pygraphviz

我正在尝试使用mod_wsgi在Apache 2.4.7下运行Python Flask应用程序。它的主要目的是建立一个人和他们的兴趣图,并在它们之间建立联系(例如,如果A和B都对PHP感兴趣,那么将有一个A< - > PHP< - > B链接)。

我已手动编译Graphviz,因为Ubuntu软件包禁用了GTS,应用程序需要该功能。我使用的编译选项是:--disable-static --with-x --with-gts --disable-ruby --disable-tcl

我使用sudo pip install pygraphviz安装了pygraphviz。我在Ubuntu 14.04上使用Python 2.7.6。

似乎导致问题的基本代码是:

import pygraphviz as pgv 
graph = pgv.AGraph(overlap = 'false', name = name)
# Add nodes
graph.layout(prog = 'neato')

这在命令行上运行正常,但是当我在Apache下运行时,我在错误日志中得到内部服务器错误和以下回溯:

[Mon Jan 12 13:45:38.228420 2015] [:error] [pid 19500:tid 140471782790912] Traceback (most recent call last):
[Mon Jan 12 13:45:38.228427 2015] [:error] [pid 19500:tid 140471782790912]   File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1817, in wsgi_app
[Mon Jan 12 13:45:38.228434 2015] [:error] [pid 19500:tid 140471782790912]     response = self.full_dispatch_request()
[Mon Jan 12 13:45:38.228459 2015] [:error] [pid 19500:tid 140471782790912]   File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1477, in full_dispatch_request
[Mon Jan 12 13:45:38.228465 2015] [:error] [pid 19500:tid 140471782790912]     rv = self.handle_user_exception(e)
[Mon Jan 12 13:45:38.228471 2015] [:error] [pid 19500:tid 140471782790912]   File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1381, in handle_user_exception
[Mon Jan 12 13:45:38.228476 2015] [:error] [pid 19500:tid 140471782790912]     reraise(exc_type, exc_value, tb)
[Mon Jan 12 13:45:38.228481 2015] [:error] [pid 19500:tid 140471782790912]   File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1475, in full_dispatch_request
[Mon Jan 12 13:45:38.228489 2015] [:error] [pid 19500:tid 140471782790912]     rv = self.dispatch_request()
[Mon Jan 12 13:45:38.228594 2015] [:error] [pid 19500:tid 140471782790912]   File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1461, in dispatch_request
[Mon Jan 12 13:45:38.228603 2015] [:error] [pid 19500:tid 140471782790912]     return self.view_functions[rule.endpoint](**req.view_args)
[Mon Jan 12 13:45:38.228609 2015] [:error] [pid 19500:tid 140471782790912]   File "/home/paul/supervisor-finder/flask/supervisorfinder.py", line 154, in show_person
[Mon Jan 12 13:45:38.228614 2015] [:error] [pid 19500:tid 140471782790912]     graph = build_graph(graph_name, results, topics)
[Mon Jan 12 13:45:38.228659 2015] [:error] [pid 19500:tid 140471782790912]   File "/home/paul/supervisor-finder/flask/supervisorfinder.py", line 124, in build_graph
[Mon Jan 12 13:45:38.228668 2015] [:error] [pid 19500:tid 140471782790912]     graph.layout(prog = 'neato')
[Mon Jan 12 13:45:38.228674 2015] [:error] [pid 19500:tid 140471782790912]   File "/usr/lib/pymodules/python2.7/pygraphviz/agraph.py", line 1305, in layout
[Mon Jan 12 13:45:38.228679 2015] [:error] [pid 19500:tid 140471782790912]     data=self._run_prog(prog,' '.join([args,"-T",fmt]))
[Mon Jan 12 13:45:38.228684 2015] [:error] [pid 19500:tid 140471782790912]   File "/usr/lib/pymodules/python2.7/pygraphviz/agraph.py", line 1278, in _run_prog
[Mon Jan 12 13:45:38.228728 2015] [:error] [pid 19500:tid 140471782790912]     raise IOError("".join(errors))
[Mon Jan 12 13:45:38.228736 2015] [:error] [pid 19500:tid 140471782790912] IOError

我的WSGI配置文件是:

import sys
import logging

sys.path.insert(0, '/home/paul/supervisor-finder/flask')
logging.basicConfig(stream=sys.stderr)

from supervisorfinder import app as application

我首先想到的问题可能与此问题相同:PyGraphViz agraph.layout() throws I0 error但我检查了agraph.py的来源并且没有调用_get_prog函数。

有人可以建议可能出错吗?我是Python的新手(通常我使用的是C风格的语言,如Perl和PHP),所以我可能会犯“明显”错误。

0 个答案:

没有答案