pycallgraph与pycharm不起作用

发布于 2021-01-29 18:12:16

我正在使用Mac OS X并尝试设置pycallgraph。
香港专业教育学院安装pycallgraph与pip和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/->项目目录


它要我做什么?

关注者
0
被浏览
53
1 个回答
  • 面试哥
    面试哥 2021-01-29
    为面试而生,有面试问题,就找面试哥。

    答案是:

    在菜单栏中:
    Pycharm-> Run->Edit Configurations...

    在对话框中:
    对于所选.py文件或对于默认值/ Python:

    环境字段组:

    Environment variables> ...-> +->
    添加条目:
    名称:PATH
    值:/usr/local/bin

    Include print environment variables 应该选择



知识点
面圈网VIP题库

面圈网VIP题库全新上线,海量真题题库资源。 90大类考试,超10万份考试真题开放下载啦

去下载看看