Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#15737 closed Bug (worksforme)

Importing hotshot.stats fails

Reported by: adamnelson Owned by: nobody
Component: Core (Other) Version: 1.3
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description (last modified by kmtracey)

Trying to import hotshot.stats from Python succeeds while using the Django shell fails.

(example-env)Adam-Nelsons-MacBook-Pro:example adam$ ./manage.py shell
Python 2.7.1 (r271:86832, Mar 23 2011, 10:01:47) 
[GCC 4.2.1 (Apple Inc. build 5664)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> import hotshot.stats
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/usr/local/Cellar/python/2.7.1/lib/python2.7/hotshot/stats.py", line 74, in <module>
    class Profile(profile.Profile):
AttributeError: 'module' object has no attribute 'Profile'
>>> 
(example-env)Adam-Nelsons-MacBook-Pro:example adam$ python
Python 2.7.1 (r271:86832, Mar 23 2011, 10:01:47) 
[GCC 4.2.1 (Apple Inc. build 5664)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import hotshot.stats
>>> 

Change History (3)

comment:1 Changed 4 years ago by adamnelson

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

Meh - Python works. I can't edit the description.

comment:2 Changed 4 years ago by kmtracey

  • Description modified (diff)
  • Resolution set to worksforme
  • Status changed from new to closed

I think you must have a module named profile in your Django example app? At least that is one way I can recreate your error. Prior to creating the profile module in my test project I had no trouble importing hotshot.stats:

C:\u\kmt\software\web\playground>"\bin\Python27\python.exe" manage.py shell
Python 2.7.1 (r271:86832, Nov 27 2010, 18:30:46) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> import hotshot.stats
>>> quit()

C:\u\kmt\software\web\playground>mkdir profile

C:\u\kmt\software\web\playground>touch profile\__init__.py

C:\u\kmt\software\web\playground>"\bin\Python27\python.exe" manage.py shell
Python 2.7.1 (r271:86832, Nov 27 2010, 18:30:46) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> import hotshot.stats
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "C:\bin\Python27\lib\hotshot\stats.py", line 74, in <module>
    class Profile(profile.Profile):
AttributeError: 'module' object has no attribute 'Profile'
>>>

comment:3 Changed 4 years ago by adamnelson

I do have an app named profile. Thanks.

Note: See TracTickets for help on using tickets.
Back to Top