安装html5lib,Html5Lib安装在Python 3.5而不是2.7

Traceback (most recent call last):

File "scrapeRecipe.py", line 29, in

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是目前

['/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']

我安装html5lib用命令easy_install html5lib。当我跑了,我得到这个消息:

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

我关心使用python 3.5它时,我的sys.path是看着我的2.7 Python代码在2.7上运行的DD。另外,我的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时,我没有。如果我尝试sudo pip install html5lib,我得到这个丑陋消息:

76d3cde7147186b52fc542778518b7f8.png

这个错误是什么消息呢? pip freeze怎么可能不会返回html5lib,当我知道html5lib.py是Python/2.7/site-packages/bs4/builder?

2017-04-27

Matt

+0

您具体是如何安装该模块?并且请注意,Traceback不会自己查看模块,它只是帮助查找异常的工具。它是Python本身在执行'import ' –

+0

时寻找必要的模块我使用“easy_install html5lib”安装了html5lib。当我运行该命令时,它说'将html5lib 0.999999999添加到easy-install.pth文件 使用/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages 处理html5lib的依赖关系。 –

+0

检查模块是否安装的最简单方法是在解释器中尝试'import '。如果它什么都没说,模块就安装好了。如果有例外......你知道演习。也许你可以尝试这种检查方法? –

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值