2016-10-07 10 views
0

mechanize codeを使用できません)。エラーにつながる部分はpython3.5でそれを実行する場合、私はまた「ImportError:Pythonで機械翻訳の名前をインポートできません」

を試してみました

#!/usr/bin/python 
import re 
from mechanize import 
br = Browser() 

ですが、私は次のエラーを見つける:

# 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() 

また、私は

easy_install mechanize 

答えて

0

mechanizeをインストールしているエラー

# 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.Browserをしようとしたことがありますか?

+0

'機械翻訳のインポートを必要としないコードを表示する' machineize.Browser()を実行するブラウザ 'が'機械化からブラウザをインポートする 'が削除された場合、 'AttributeError: 'module'オブジェクトに属性 'Browser''がありません – user123456

+0

私の答えは速すぎました。あなたがPython <3.Xでないことを確認してください。 http://wwwsearch.sourceforge.net/mechanize/faq.html – pacode

+0

あなたは正しいです。私のものはPython 2.7でした。どうもありがとうございます。 – user123456

0

pythonバージョンは、少なくとも3.0reference

readlink -f $(which python) | xargs -I % sh -c 'echo -n "%: "; % -V' 

であなたのPythonのバージョンを確認しなければならない。しかし、エラーがこのことからだけ来ませんでした。 mechanizeが正しくインストールされていないため、source codeから再度インストールします。

関連する問題