Domanda

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.

È stato utile?

Soluzione

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

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top