【发布时间】:2013-12-18 11:16:51
【问题描述】:
我正在使用 mac os x 并尝试设置 pycallgraph。
我已经用 pip 安装了 pycallgraph,用 homebrew 安装了 graphviz。
一切都从外壳工作。
但不是来自pycharm。
from pycallgraph import PyCallGraph
from pycallgraph import Config
from pycallgraph import GlobbingFilter
from pycallgraph.output import GraphvizOutput
config = Config()
config.trace_filter = GlobbingFilter(exclude=[
'pycallgraph.*',
])
graphviz = GraphvizOutput(output_file='filter_exclude.png')
with PyCallGraph(output=graphviz, config=config):
def my_fun():
print "HELLO"
my_fun()
/Users/user/Projects/py27/bin/python /Users/user/Projects/py27_django/test2.py
Traceback (most recent call last):
File "/Users/user/Projects/py27_django/test2.py", line 15, in <module>
with PyCallGraph(output=graphviz, config=config):
File "/Users/user/Projects/py27/lib/python2.7/site-packages/pycallgraph/pycallgraph.py", line 32, in __init__
self.reset()
File "/Users/user/Projects/py27/lib/python2.7/site-packages/pycallgraph/pycallgraph.py", line 53, in reset
self.prepare_output(output)
File "/Users/user/Projects/py27/lib/python2.7/site-packages/pycallgraph/pycallgraph.py", line 97, in prepare_output
output.sanity_check()
File "/Users/user/Projects/py27/lib/python2.7/site-packages/pycallgraph/output/graphviz.py", line 63, in sanity_check
self.ensure_binary(self.tool)
File "/Users/user/Projects/py27/lib/python2.7/site-packages/pycallgraph/output/output.py", line 96, in ensure_binary
'The command "{}" is required to be in your path.'.format(cmd))
pycallgraph.exceptions.PyCallGraphException: The command "dot" is required to be in your path.
Process finished with exit code 1
这里:/Users/user/Projects/py27/ -> virtualenv 目录/Users/user/Projects/py27_django/ -> 项目目录
它想从我这里得到什么?
【问题讨论】:
-
它希望
dot命令(来自 graphviz)在您的路径中。如果您启动一个终端并执行which dot,它会找到您使用自制软件安装的dot二进制文件吗? -
您可能会遇到这个问题:PyCharm - $PATH on OS X
-
@LukasGraf 是的,当然:它是
/usr/local/bin/dot。正如我所说,shell 一切正常。很明显,我必须在某处添加这条路径,但是在哪里呢?? -
查看我链接的问题及其答案:自制链接包到
/usr/local/bin,默认$PATH中没有。您的.bash_profile可能会将其添加到$PATH,但这仅适用于终端。将/usr/local/bin/附加到您的PyCharm 配置中的$PATH,如this answer 中所述,您应该没问题。 -
@LukasGraf 感谢您提及graphviz。男孩,我很难弄清楚
dot来自哪里