我无法使用mechanize code)。导致错误的部分是
#!/usr/bin/python
import re
from mechanize import
br = Browser()
我也试过
使用python3.5执行时,我发现以下错误:
# python mechanize.py
Traceback (most recent call last):
File "mechanize.py", line 6, in <module>
from mechanize import Browser
File "/root/git/stakexchange-ask-question/mechanize.py", line 6, in <module>
from mechanize import Browser
ImportError: cannot import name Browser
然而,这正是官方mechanize website
的建议如果我将代码修改为
#!/usr/bin/python
import re
br = mechanize.Browser()
我也收到错误
# python mechanize.py
Traceback (most recent call last):
File "mechanize.py", line 5, in <module>
import mechanize
File "/root/git/stakexchange-ask-question/mechanize.py", line 6, in <module>
br =mechanize.Browser()
AttributeError: module 'mechanize' has no attribute 'Browser'
我已经使用
安装了mechanize
easy_install mechanize
答案 0 :(得分:0)
您是否尝试过mechanize.Browser()?
答案 1 :(得分:0)
python
版本必须至少3.0
(reference)
使用
检查你的python版本readlink -f $(which python) | xargs -I % sh -c 'echo -n "%: "; % -V'
但错误并非仅来自此。 mechanize
未正确安装,我再次从source code安装。