6

I have ran kernprof on a file called RP.py and it spits out RP.py.lprof

Now, i'm trying to view this file. If i open a cmd window and type python -m line_profiler RP.py.lprof it gives me the text, but it not formatted in a way that I can read it.

Is there a way to 1) turn lprof into text?

or run it in a shell. I have tried:

import sys
import subprocess
subprocess.call([sys.executable,'C:\\Python27\\python.exe', '-m', 'line_profiler', 'RP.py.lprof'])

Execute a file with arguments in Python shell from this link. But this doesn't work.

Community
  • 1
  • 1
jason
  • 3,811
  • 18
  • 92
  • 147
  • I don't have ready access to a Windows box, but my first guess based on the description is that the line-endings are \n instead of \r\n. Try piping the results to a text file and then open it in a programmer's editor (not Notepad). `python -m line_profiler RP.py.lprof > results.txt` – TML May 06 '14 at 15:06
  • worked. if you put it in an answer. I will accept it. – jason May 06 '14 at 15:09
  • I'm not familiar with kernprof, so I almost didn't say anything, but glad you got a usable result. :) – TML May 06 '14 at 15:10

1 Answers1

9

I don't have ready access to a Windows box, but my first guess based on the description is that the line-endings are \n instead of \r\n. Try piping the results to a text file and then open it in a programmer's editor (not Notepad).

python -m line_profiler RP.py.lprof > results.txt

TML
  • 12,813
  • 3
  • 38
  • 45
  • Note that there might also be a solution to this that is more idiomatic to a Windows user, which I might not be aware of. This is just the 10lb. sledge I break out when line-endings are goofed up. – TML May 06 '14 at 15:15