Hi I'm a newbie Python programmer. I want line by line profiling and so have tried to install the line_profiler package. But it's not working. Here is what I have done:
By the way I'm on Windows 8.1, 64 bit and I'm using Enthought Canopy.
I got the Windows install package from here: https://pypi.python.org/pypi/line_profiler and installed it.
It says on the line_profiler site that a) I don't need to build it or need Cython, b) that I should do this:
For IPython 0.11+, you can install it by editing the IPython configuration file ~/.ipython/profile_default/ipython_config.py to add the 'line_profiler' item to the extensions list:
c.TerminalIPythonApp.extensions = [ 'line_profiler', ]
I restarted Canopy, no luck. There should be a magic command %lprun. It's not there.
I tried %load_ext line_profiler but got this message:
C:\Users\OEM\AppData\Local\Enthought\Canopy\User\lib\site-packages\line_profiler.py in () 10 import sys 11 ---> 12 from _line_profiler import LineProfiler as CLineProfiler 13 14
ImportError: DLL load failed: %1 is not a valid Win32 application.
Other things: I looked for a setup.py for this but couldn't find one for the line_profiler which seems to be installed in the C:\Users\OEM\AppData\Local\Enthought\Canopy\User\Lib\site-packages folder.
So any help appreciated please.
Im using Windows 10, 64 bit
Output in cmd
(Original source)
Even though this question is quite old:
Nowadays, using miniconda
/Anaconda
, installation under Win 10 64-bit works like a charm; just do conda install line_profiler
in the environment you are going to use. This will also add the kernprof
command/script to your path in that environment.
Usage:
[add @profile decorators to the functions you want to profile]
kernprof -l ./your_script.py
python -m line_profiler ./your_script.py.lprof
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With