gpt4 book ai didi

python - pycharm 的 pycallgraph 不起作用

转载 作者:太空狗 更新时间:2023-10-29 17:01:58 32 4
gpt4 key购买 nike

我正在使用 mac os x 并尝试设置 pycallgraph。
我用 pip 安装了 pycallgraph,用 homebrew 安装了 graphviz。
一切都在 shell 中工作。但不是来自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/ -> 项目目录


它想从我这里得到什么?

最佳答案

在 MacOS 中安装 graphviz 使用:

brew 安装 graphviz

或在 Ubuntu 中使用:

sudo apt-get install graphviz

然后您可以使用以下方法测试dot:

点-v

您还可以从 here 下载 pkg

关于python - pycharm 的 pycallgraph 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20333530/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com