Python: module does not have mechanize attribute

#!/usr/bin/env python
import mechanize

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

It 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 embarrassed. I have installed the module for 2.6 and 2.7, the same result ...

+3
source share
1 answer

Change the file name in the mechanize.py file. Python imports your file as a module.

+18
source

Source: https://habr.com/ru/post/1776038/


All Articles