我无法使用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发布于 2016-10-07 19:58:14
你试过mechanize.Browser()吗?
发布于 2016-10-07 20:13:49
python版本必须至少为3.0 (reference)
检查您的python版本
readlink -f $(which python) | xargs -I % sh -c 'echo -n "%: "; % -V'但是错误不仅仅来自于此。mechanize没有正确安装,我从source code重新安装了它。
https://stackoverflow.com/questions/39916657
复制相似问题