Skip to content

Instantly share code, notes, and snippets.

@kylegibson
Last active June 27, 2022 14:34
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save kylegibson/6583590 to your computer and use it in GitHub Desktop.
Save kylegibson/6583590 to your computer and use it in GitHub Desktop.
from decorator import decorator
from line_profiler import LineProfiler
@decorator
def profile_each_line(func, *args, **kwargs):
profiler = LineProfiler()
profiled_func = profiler(func)
try:
profiled_func(*args, **kwargs)
finally:
profiler.print_stats()
@Jaya472
Copy link

Jaya472 commented Jun 22, 2022

I am not able to see the Line Contents. Only the #hits, #time, etc are being shown. The output says

"Could not find file C:\Users\HP\AppData\Local\Temp\ipykernel_24440\670606222.py
Are you sure you are running this program from the same directory that you ran the profiler from?"

It used to work few months ago but suddenly now the above is happening. And I write my scripts in Onedrive with Anaconda Jupyter Lab. Please suggest what might be wrong. There is NO answer anywhere for this problem and I tried every possible way I could think of to solve it from 8 hours! Just to get the Line Contents so that I can begin my actual task of optimizing my code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment