由于html5lib错误,pip无法安装模块(pip cannot install module due to html5lib error)

我想在win7中建立一个tensorflow环境。 我按照这里的说明进行操作,我想我已经安装了tensorflow。 我设法在前一个链接中运行小脚本,但仅在Anaconda tensorflow环境的控制台内。 由于windows的控制台有点原始(有礼貌),我想安装Ipython。 问题是我在尝试使用pip时遇到错误。 例如:

pip install pyreadline

给出这个

回溯(最近一次调用最后一次):文件“D:\ Software \ Anaconda3 \ Scripts \ pip-script.py”,第6行,来自pip import主文件“D:\ Software \ Anaconda3 \ lib \ site-packages \ pip__init__ .py“,第28行,来自pip.vcs import git,mercurial,subversion,bazaar #noqa文件”D:\ Software \ Anaconda3 \ lib \ site-packages \ pip \ vcs \ subversion.py“,第9行,in从pip.index导入链接文件“D:\ Software \ Anaconda3 \ lib \ site-packages \ pip \ index.py”,第33行,从pip._vendor导入html5lib,请求,六个ImportError:无法导入名称'html5lib'

使用一些说明我也试过这个:

python -m pip install pyreadline

具有相同的输出。 我认为pyreadline被认为是Ipython的先决条件。 如果我的控制台升高或没有升高没有区别。

一般来说,似乎所有模块的安装尝试都会产生相同的消息。 甚至: pip install --ignore-installed --upgrade html5lib这样做。

我的系统是win7,python 3.6.2,我使用Anaconda的指令安装了tensorflow 。 从Anaconda Navigator我看到安装了html5lib。 那么,如何绕过这个问题才能安装新模块呢?

编辑:我按照这里有类似我的问题的说明,但虽然接受了答案,但它没有解决问题。 html5lib似乎重新安装,但其他模块不是。

I am trying to set up a tensorflow environment in win7. I followed the instructions here and I guess I have installed tensorflow. I managed to run the small script in the previous link but only inside the console of Anaconda tensorflow environment. Since the windows' console is a bit primitive (to be polite) I would like to install Ipython. The problem is I am getting an error when trying to use pip. For example:

pip install pyreadline

gives this

Traceback (most recent call last): File "D:\Software\Anaconda3\Scripts\pip-script.py", line 6, in from pip import main File "D:\Software\Anaconda3\lib\site-packages\pip__init__.py", line 28, in from pip.vcs import git, mercurial, subversion, bazaar # noqa File "D:\Software\Anaconda3\lib\site-packages\pip\vcs\subversion.py", line 9, in from pip.index import Link File "D:\Software\Anaconda3\lib\site-packages\pip\index.py", line 33, in from pip._vendor import html5lib, requests, six ImportError: cannot import name 'html5lib'

Using some instructions I also tried this one:

python -m pip install pyreadline

with the same output. pyreadline is considered prerequirement for Ipython I think. If my console is elevated or not does no difference.

Generally speaking it seems all modules' installation attempts produce the same message. Even: pip install --ignore-installed --upgrade html5lib does so.

My system is win7, python 3.6.2 and I installed tensorflow using the instruction for Anaconda. From Anaconda Navigator I see html5lib as installed. So, how can bypass this problem to be able to install new modules?

Edit: I followed the instructions here which had a similar to mine problem but although accepted as an answer there it didn't solve the problem. html5lib seems to be reinstalled but other modules are not.

原文:https://stackoverflow.com/questions/46831127

更新时间:2019-10-05 22:17

最满意答案

我的问题的解决方案是作为这个(非常相似)的答案,但也是4年的问题 。

问题是我实际工作的解决方案不是公认的,所以我提供第二个答案作为我的问题的解决方案。

使用:

conda install -c anaconda html5lib

The solution to my problem came as an answer to this (very similar) but also 4 years old question.

The problem is that the solution for me that actually worked is not the accepted one, so I am providing the second answer as the solution to my problem.

Using:

conda install -c anaconda html5lib

seems to unravel the dependencies and make pip work again. ref: https://anaconda.org/anaconda/html5lib

相关问答

我升级了beautifulsoup4和html5lib,它解决了这个问题。 pip install --upgrade beautifulsoup4

pip install --upgrade html5lib

edit nov, 2017: it seems this doesn't work any more Finally found out, a search engine didn't throw anything but it's referenced on beautifulsou

...

El Capitan配备了一个不能修改的旧版本的六个安装版本。 Pip试图卸载它作为升级的一部分,不能这样做。 尝试这个: pip install retrying --ignore-installed six

理想情况下,您将使用virtualenv,它将允许您安装所有必需的版本。 El Capitan comes with an older version of six installed which cannot be modified. Pip is trying to uninstal

...

尝试运行conda update -f html5lib ,它会尝试更新你的html5lib 。 我通过tensorflow安装了一些东西( tensorflow )之后也遇到了这个问题,这个问题必须降级html5lib并打破pip所有内容。 Try running conda update -f html5lib which will try to update your html5lib. I also encountered this after installing something (

...

你错过了six模块。 你可以从这里下载,或者更好,使用pip install six 。 You're missing the six module. You can download it from here, or better, use pip install six .

我发现html5lib的最新版本在bs4方面有些问题, html5lib.treebuilders._base不再存在,usng bs4 4.4.1最新的兼容版本似乎是7个9的版本,一旦你安装了如下它工作正常: pip3 install -U html5lib=="0.9999999"

使用bs4 4.4.1进行测试: In [1]: import bs4

In [2]: bs4.__version__

Out[2]: '4.4.1'

In [3]: import html5lib

In

...

从错误中可以明显看出,软件包版本不匹配。 你有几个选择从这里。 如果您尚未安装tensorboard ,请安装tensorboard并查看错误是否已解决: pip install tensorboard 如果已安装tensorboard,请使用以下命令卸载tensorboard: pip uninstall tensorboard并指定要安装的tensorboard的版本: pip install tensorboard=1.5.1 。 有关更多详情,请参阅此处 It is clear from

...

事实证明,我从现场网站复制文件的位置,我的wsgi文件仍然指向实时vertualenv。 import os

import sys

import site

site.addsitedir('/var/www/path/to/file/lib/python2.6/site-packages')

It turns out where i had copied the files across from the live site, my wsgi file was still pointing at

...

元素game-header-body不存在于HTML源代码中,但稍后通过javascript呈现。 你需要像硒这样的东西来帮助解决这个问题。 它可以加载您选择的浏览器(如果需要,包括无头的浏览器),然后为您执行javascript。 然后,您可以在页面完全加载后访问生成的HTML,并使用BeautifulSoup对其进行解析。 以下是使用已安装的Firefox浏览器如何完成此操作的示例: from bs4 import BeautifulSoup

from selenium import webd

...

我的问题的解决方案是作为这个(非常相似)的答案,但也是4年的问题 。 问题是我实际工作的解决方案不是公认的,所以我提供第二个答案作为我的问题的解决方案。 使用: conda install -c anaconda html5lib

似乎解开了依赖关系并使pip重新工作。 参考: https : //anaconda.org/anaconda/html5lib The solution to my problem came as an answer to this (very similar) b

...

更多推荐