【发布时间】:2021-07-27 03:03:31
【问题描述】:
我正在尝试使用 pyinstrument 分析 python 程序,但在尝试以 html 呈现配置文件时它不断抛出此错误。
Traceback (most recent call last):
File "/home/ananda/projects/product_pred/025200812_cpall_ai_ordering_model_v2/.venv/bin/pyinstrument", line 8, in <module>
sys.exit(main())
File "/home/ananda/projects/.venv/lib/python3.8/site-packages/pyinstrument/__main__.py", line 304, in main
output_filename = renderer.open_in_browser(session)
File "/home/ananda/projects.venv/lib/python3.8/site-packages/pyinstrument/renderers/html.py", line 70, in open_in_browser
f.write(self.render(session))
File "/home/ananda/projects/.venv/lib/python3.8/site-packages/pyinstrument/renderers/html.py", line 25, in render
raise RuntimeError(
RuntimeError: Could not find app.js. If you are running pyinstrument from a git checkout, run 'python setup.py build' to compile the Javascript (requires nodejs).
似乎我没有 nodejs,所以我尝试通过 sudo apt install nodejs 安装它,但我遇到了同样的错误。
我知道错误要求我运行python setup.py build,但我什至没有用于我的 repo 的 setup.py 文件,所以我不确定应该做什么。我是从 pyinstrument 的安装文件夹中运行它吗?我尝试进入那里,但在那里也找不到 setup.py 文件(在.venv/lib/python3.8/site-packages/pyinstrument 下)
我试图运行的文件是一个简单的脚本,所以我认为这并不重要。
import time
time.sleep(2)
print("hello, world")
我运行程序的方式是这样的-
pyinstrument -r html src/jobs/evaluator.py
如果我尝试在不使用 html 渲染的情况下运行 pyinstrument,pyinstrument src/jobs/evaluator.py,它可以工作,但输出在终端中,我真的很想要 html 输出。
我想我只是在这里缺少一些 javascript 依赖项,但我不确定要安装什么或如何安装它。
我正在使用以下版本-
python 3.8.10
pyinstrument 4.0.0
node v8.10.0
OS - Pop!_OS 18.04 LTS
感谢您的帮助!
【问题讨论】:
标签: javascript python node.js python-3.x profiling