2017-04-27 1 views
0

のPython 3.5にインストールされていないが、私はこの厄介なエラーを取得されています:Html5Lib 2.7

Traceback (most recent call last): 
    File "scrapeRecipe.py", line 29, in <module> 
    br.select_form(name="aspnetForm") 
    File "build/bdist.macosx-10.11-intel/egg/mechanize/_mechanize.py", line 619, in select_form 
    File "build/bdist.macosx-10.11-intel/egg/mechanize/_html.py", line 260, in global_form 
    File "build/bdist.macosx-10.11-intel/egg/mechanize/_html.py", line 267, in forms 
    File "build/bdist.macosx-10.11-intel/egg/mechanize/_html.py", line 282, in _get_forms 
    File "build/bdist.macosx-10.11-intel/egg/mechanize/_html.py", line 247, in root 
    File "build/bdist.macosx-10.11-intel/egg/mechanize/_html.py", line 145, in content_parser 
ImportError: No module named html5lib 

私はトレースバックは、これらのファイルを見ている理由を理解しようとしています。また、私がlocate build/bdist.macosx-10.11-intel/egg/mechanize/_mechanize.pyをすると、それは存在しないと私に伝えます。

html5libモジュールが/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/_vendor/html5libにあるため、このモジュールが見つかりませんでした。

質問:トレースバックの表示位置を制御できますか?また、私のsys.pathは、私は、コマンドeasy_install html5libでhtml5libインストール現在

['/Users/madelinezechar/eatLowCarbon', '/Library/Python/2.7/site- 
packages/BeautifulSoup-3.2.1-py2.7.egg', '/Library/Python/2.7/site- 
packages/html2text-2016.9.19-py2.7.egg', '/Library/Python/2.7/site- 
packages/mechanize-0.3.1-py2.7.egg', '/Library/Python/2.7/site- 
packages/requests-2.13.0-py2.7.egg', '/Library/Python/2.7/site- 
packages/pip-9.0.1-py2.7.egg', 
    '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip', 
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac',  '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages',  '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python',  '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old',  '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload', 
'/Users/madelinezechar/Library/Python/2.7/lib/python/site-packages',  '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC', 
'/Library/Python/2.7/site-packages'] 

です。私はそれを実行したとき、私はこのメッセージが表示されます。

Adding html5lib 0.999999999 to easy-install.pth file 

Using /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages 
Processing dependencies for html5lib 
Finished processing dependencies for html5lib 

私のsys.pathが2.7を見ているときに私のpython 3.5を使用して、それが心配ですDDを私のPythonコードは2.7上で実行されます。また、私のeasy_install.pthても、インストール後に、html5libを持っているように見えません。

import sys; sys.__plen = len(sys.path) 

./BeautifulSoup-3.2.1-py2.7.egg 
    ./html2text-2016.9.19-py2.7.egg 
    ./mechanize-0.3.1-py2.7.egg 
    ./requests-2.13.0-py2.7.egg 
    ./pip-9.0.1-py2.7.egg 
    import sys; new=sys.path[sys.__plen:]; del sys.path[sys.__plen:]; p=getattr(sys,'__egginsert',0); sys.path[p:p]=new; sys.__egginsert = p+len(new) 

私はpip3 freezeを実行すると、私はhtml5libがリスト表示されます。 pip freezeを実行すると、私はしません。

enter image description here

このエラーメッセージは何を意味している:私はsudo pip install html5libをしようとすると、私はこの醜いメッセージが表示されますか? html5lib.pyPython/2.7/site-packages/bs4/builderにあることを知っている場合、pip freezeはどのように返されますか?html5lib

+0

あなたをどうやって正確にそのモジュールをインストールしますか?また、Tracebackはモジュールの内部を調べていないことに注意してください。これは、例外を特定するのに役立つ単なるツールです。 'import ' –

+0

を実行するときにPython自体が必要なモジュールを探しています。「easy_install html5lib」を使用してhtml5libをインストールしました。このコマンドを実行すると、 'easy_install.pthファイルにhtml5lib 0.999999999を追加すると、 /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages html5libの処理依存関係があります。 – Matt

+0

モジュールがインストールされているかどうかを確認する最も簡単な方法は、インタプリタで 'import 'を試してみることです。何も言わなければ、モジュールがインストールされます。例外がある場合...あなたはドリルを知っています。チェックの方法を試してみてください。 –

答えて

0

私は別のエラーを取得していますが、Pythonの2.7 html5libをインストールするには、これは私のソリューションです:

pip install --ignore-installed six --user 
sudo -H pip install html5lib --ignore-installed 

の詳細を学ぶために、これは優れたスレッドです:https://github.com/pypa/pip/issues/3165