pythonline-profiler

line_profiler and kernprof does not work installed from pip and repro


I have tried what has been suggested. On the simplest of code, I get the familiar error that others have mentioned. The error is:

@profile
NameError: name 'profile' is not defined

on the minimal code:

@profile
def hello():
  print('Testing')

hello()

from the command line:

kernprof -l hello.py

I have imported future and I have even installed from the distribution outside of my virtualenv. This was a previous suggestion, as was importing future module.

So

import future
import cProfile

@profile
def hello():
  print('Testing')

hello()

also gives the same error. I cannot get this line profiler to work with pip or even from the raw repository. My versions are:

pip 8.1.2
python 2.7

Solution

  • I fixed this my cloning the code from https://github.com/rkern/line_profiler and rebuilding and then calling the kernprof from the binary install location.