开发者

python: module has no attribute mechanize

#!/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()
AttributeErro开发者_运维知识库r: 'module' object has no attribute 'Browser'

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


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜