8

So I've looked around everywhere for help on how to install cProfile and I've found nothing. When this usually happens I turn to pip and run the usual: 'pip install [module name]' but I'm getting the error: No matching distribution found for cprofile.

I have no idea how to install cProfile and I've looked everywhere. I rarely turn to StackOverflow and when I did I thoroughly searched it for a question like this.

Any help would be appreciated.

Shorthand question: How do I install cProfile?

  • 4
    cProfile should be part of the standard library. What happens if you do `import cProfile` in the interpreter? – snakecharmerb Apr 14 '16 at 12:31
  • ImportError: No module named 'cprofile' –  Apr 14 '16 at 12:54
  • 1
    The import statement is case-sensitive - did you use a capital 'P'?, also what is the output of `python -c 'import sys;print sys.version; print sys.platform'` executed at the command prompt? – snakecharmerb Apr 14 '16 at 12:58

1 Answers1

11

Normally it is included in the Python's standard library. What Python version are you using? You can verify that with:

python -V

What pip version are you using? You can verify that with:

pip -V

and upgrade it with:

pip install -U pip

What is the output when you try to run cProfile in package mode directly through the bash, like:

python -m cProfile -o profile_output script.py

Morevover, the official documentation recommends using profile if cProfile is not available on your system, as they are mostly interchangeable. Please refer to The Python Profilers Official Documentation.

mschuh
  • 156
  • 5
  • Python version is 3.5.1 and pip version is 8.1.1. My pip is latest and the result for the last one is no module named cprofile. –  Apr 14 '16 at 12:54
  • 2
    Are you really sure you are not messing up with the cases? `cprofile` and `cProfile` are two different things for the python interpreter. – mschuh Apr 14 '16 at 13:10
  • 1
    I fixed the problem. So when I reinstalled Python (after reinstalling the OS) the download got messed up. I reinstalled it, this time checking the hash, and it worked. Also thank you to the users that told me about the module being case-sensitive. I was trying 'cprofile' instead of 'cProfile' which wasn't the problem but was good to know after! –  Apr 19 '16 at 10:29