[Tutor] strange hotshot error

tpc at csua.berkeley.edu tpc at csua.berkeley.edu
Tue Mar 15 20:57:55 CET 2005

hi everyone, to anyone who has profiled their Python code using hotshot; I
designed a test case using hotshot that is basically a stripped down
version of the example code found here:


So I tried using the example code verbatim to see if I get the same error
messages, and I do!  When I try "import hotshot.stats" I get:

>>> import hotshot.stats

Traceback (most recent call last):
  File "<pyshell#1>", line 1, in -toplevel-
    import hotshot.stats
  File "/usr/lib/python2.3/hotshot/stats.py", line 3, in -toplevel-
    import profile
ImportError: No module named profile

When I try "import hotshot.stats" again I get no error message, so I
assume the import on the second try has found the module.  Everything
seems honky dory until I try "stats = hotshot.stats.load("stones.prof")":

>>> stats = hotshot.stats.load("stones.prof")

Traceback (most recent call last):
  File "<pyshell#13>", line 1, in -toplevel-
    stats = hotshot.stats.load("stones.prof")
AttributeError: 'module' object has no attribute 'load'

I've confirmed the stones.prof file exists and that I am in the same
directory where the file is, so I am in a situation where IDLE is telling
me hotshot.stats has no attribute 'load'.  I've confirmed hotshot.stats
does indeed have attribute 'load' from:


so now I am at my wit's end as to what the problem is.  I can't use
hotshot since I can't load the profile data.  Am I doing something wrong ?

More information about the Tutor mailing list