3
#!/usr/bin/env python
import mechanize

mech = mechanize.Browser()
page = br.open(SchoolRank('KY'))

Gives:

Traceback (most recent call last):
  File "mechanize.py", line 2, in <module>
    import mechanize
  File "/home/jcress/Documents/programming/schooldig/trunk/mechanize.py", line 12, in <module>
    mech = mechanize.Browser()
AttributeError: 'module' object has no attribute 'Browser'

And I'm confused. I have the module installed for 2.6 and 2.7, same result...

blahdiblah
  • 33,069
  • 21
  • 98
  • 152
justin cress
  • 1,745
  • 5
  • 24
  • 35

1 Answers1

18

Change your filename away from mechanize.py. Python is importing your file as the module.

Matthew Flaschen
  • 278,309
  • 50
  • 514
  • 539