Html5Lib安装在Python 3.5中,但不是2.7中

Html5Lib安装在Python 3.5中,但不是2.7中,python,python-2.7,sys,traceback,Python,Python 2.7,Sys,Traceback,我犯了一个严重的错误: 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/bdis

我犯了一个严重的错误:

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
我使用命令
easy\u install html5lib
安装了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
当我的sys.path在2.7上运行时,我担心使用Python3.5,而我的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)
当我运行
pip3freeze
时,我看到html5lib被列出。当我运行
pip freeze
时,我不会。如果我尝试
sudopip安装html5lib
,我会收到这样一条丑陋的信息:


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

我得到了一个不同的错误,但要为Python 2.7安装html5lib,这是我的解决方案:

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

要了解更多信息,这是一个优秀的线程:

您是如何安装该模块的?请注意,回溯并不是查看模块本身,它只是一个帮助定位异常的工具。在执行
import
I使用“easy\u install html5lib”安装html5lib时,Python本身正在寻找必要的模块。当我运行该命令时,它显示
使用/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages将html5lib 0.999999999添加到easy-install.pth文件中处理html5lib的依赖项
。检查模块是否已安装的最简单方法是在解释器中尝试
导入
。如果没有显示任何内容,则表示模块已安装。如果有例外。。。你知道该怎么做。也许你可以尝试这种检查方法?没有异常,但我得到的是相同的,
ImportError:没有名为html5lib的模块
这是一个异常:)这意味着模块没有安装。您不能用
pip
安装它吗?
pip install --ignore-installed six --user
sudo -H pip install html5lib --ignore-installed