0

I just installed line_profiler using pip on Ubuntu. I closed and reopened the terminal, cd'd into the directory with my file to time, and ran kernprof. Bash is telling me it can't find kernprof. Coincidentally, I just did the exact same procedure on windows and it worked fine.

EDIT: So pip didn't actually install it, or put kernprof in the wrong directory. Downloading the tarball from pypi and running setup works.

Vendea
  • 145
  • 1
  • 1
  • 9
  • Are you certain the installation was successful? As I understand it, the executable created by pip should be `/usr/bin/kernprof`. Does this file exist? Is it set executable? Does your user have permission to access it? – 0range Jun 21 '16 at 20:31
  • @0range, that is what was wrong. Pip claimed it was installed but it wasn;t. I downloaded it from pypi and ran setup. Now it works. Thank you! – Vendea Jun 21 '16 at 22:13

1 Answers1

1

If you have used instructions from the github https://github.com/rkern/line_profiler to install it, then you have probably used command: pip install . --user. The command installs a package into ~/.local/lib/python2.7/site-packages/ (or whatever is you default python python --version), and the corresponding executable is in ~/.local/bin/.

Based on this, you can run kernprof with:

~/.local/bin/kernprof -l -v my_script.py

or you can create a symlink with:

sudo ln -s ~/.local/bin/kernprof /usr/local/bin/kernprof

and then run it with:

kernprof -l -v my_script.py
cijad
  • 152
  • 3