line_profiler icon indicating copy to clipboard operation
line_profiler copied to clipboard

How to use kernprof on module?

Open yabb85 opened this issue 6 years ago • 1 comments

Hi,

I try to analyze my module but when i launch kernprof, I have the following error: ValueError: Attempted relative import in non-package I try several method to launch kernprof:

  • kernprof -l -v mymodule.__main__ the error is: IOError: [Errno 2] No such file or directory: mymodule.__main__
  • kernprof -l -v mymodule/__main__.py the error is: ValueError: Attempted relative import in non-package

Normally i use the following command to launch my script: python -m mymodule.__main__

Thank you very much

yabb85 avatar Oct 15 '18 15:10 yabb85

Here's a workaround: https://github.com/rkern/line_profiler/issues/8 You can change the pythonpath and then it should work.

ttbrunner avatar Oct 28 '18 10:10 ttbrunner