As noted in the commentary, it is likely that unexpectedly there is a file called profile.py , possibly in the current directory. This file is inadvertently used by cProfile , thereby masking the Python profile module.
Proposed Solution:
mv profile.py profiler.py
Further, for good measure,
If you are using Python 3:
rm __pycache__/profile.*.pyc
If you are using Python 2:
rm profile.pyc
ABB
source share