Tuesday 3 August 2021

Missing javascript dependency for python-pyinstrument

I am trying to profile a python program with pyinstrument but it keeps throwing this error when trying to render the profile in 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).

It seems that I don't have nodejs so I tried installing that by sudo apt install nodejs but I am getting the same error.

I know the error is asking me to run python setup.py build but I don't even have a setup.py file for my repo so I am not sure what that is supposed to do. Am I to run it from the installation folder of pyinstrument or something? I tried going in there but I can't find a setup.py file there as well (under .venv/lib/python3.8/site-packages/pyinstrument)

The file that I am trying to run is a simple script so I don't think that matters.

import time

time.sleep(2)
print("hello, world")

The way I am running the program is like so -

pyinstrument -r html src/jobs/evaluator.py

If I try running pyinstrument without using html rendering, pyinstrument src/jobs/evaluator.py, it works but the output is in the terminal and I would really like the html output.

I think I am just missing some javascript dependency here but I am not sure what or how to install it.

I am using the following versions -

python 3.8.10
pyinstrument 4.0.0
node v8.10.0
OS - Pop!_OS 18.04 LTS

Thanks for the help!



from Missing javascript dependency for python-pyinstrument

No comments:

Post a Comment