pip抛出TypeError:尝试安装新软件包时parse()得到了意外的关键字参数’transport_encoding’

问题:pip抛出TypeError:尝试安装新软件包时parse()得到了意外的关键字参数’transport_encoding’

我正在使用最新版本的Anaconda3。我刚刚安装了它,我正在尝试下载一些软件包。我正在使用Anaconda Prompt。尝试使用pip做任何事情(包括升级现有软件包)时,我得到以下回溯。

    Exception:
Traceback (most recent call last):
  File "C:\Users\csprock\Anaconda3\lib\site-packages\pip\basecommand.py", line 215, in main
    status = self.run(options, args)
  File "C:\Users\csprock\Anaconda3\lib\site-packages\pip\commands\install.py", line 335, in run
    wb.build(autobuilding=True)
  File "C:\Users\csprock\Anaconda3\lib\site-packages\pip\wheel.py", line 749, in build
    self.requirement_set.prepare_files(self.finder)
  File "C:\Users\csprock\Anaconda3\lib\site-packages\pip\req\req_set.py", line 380, in prepare_files
    ignore_dependencies=self.ignore_dependencies))
  File "C:\Users\csprock\Anaconda3\lib\site-packages\pip\req\req_set.py", line 487, in _prepare_file
    req_to_install, finder)
  File "C:\Users\csprock\Anaconda3\lib\site-packages\pip\req\req_set.py", line 428, in _check_skip_installed
    req_to_install, upgrade_allowed)
  File "C:\Users\csprock\Anaconda3\lib\site-packages\pip\index.py", line 465, in find_requirement
    all_candidates = self.find_all_candidates(req.name)
  File "C:\Users\csprock\Anaconda3\lib\site-packages\pip\index.py", line 423, in find_all_candidates
    for page in self._get_pages(url_locations, project_name):
  File "C:\Users\csprock\Anaconda3\lib\site-packages\pip\index.py", line 568, in _get_pages
    page = self._get_page(location)
  File "C:\Users\csprock\Anaconda3\lib\site-packages\pip\index.py", line 683, in _get_page
    return HTMLPage.get_page(link, session=self.session)
  File "C:\Users\csprock\Anaconda3\lib\site-packages\pip\index.py", line 811, in get_page
    inst = cls(resp.content, resp.url, resp.headers)
  File "C:\Users\csprock\Anaconda3\lib\site-packages\pip\index.py", line 731, in __init__
    namespaceHTMLElements=False,
TypeError: parse() got an unexpected keyword argument 'transport_encoding'

有任何想法吗?(这个问题只有在我安装了tensorflow之后才开始出现)谢谢。

I am using the latest version of Anaconda3. I just installed it and I am trying to download some packages. I am using the Anaconda Prompt. While trying to use pip to do anything (including upgrading existing packages) I get the following traceback.

    Exception:
Traceback (most recent call last):
  File "C:\Users\csprock\Anaconda3\lib\site-packages\pip\basecommand.py", line 215, in main
    status = self.run(options, args)
  File "C:\Users\csprock\Anaconda3\lib\site-packages\pip\commands\install.py", line 335, in run
    wb.build(autobuilding=True)
  File "C:\Users\csprock\Anaconda3\lib\site-packages\pip\wheel.py", line 749, in build
    self.requirement_set.prepare_files(self.finder)
  File "C:\Users\csprock\Anaconda3\lib\site-packages\pip\req\req_set.py", line 380, in prepare_files
    ignore_dependencies=self.ignore_dependencies))
  File "C:\Users\csprock\Anaconda3\lib\site-packages\pip\req\req_set.py", line 487, in _prepare_file
    req_to_install, finder)
  File "C:\Users\csprock\Anaconda3\lib\site-packages\pip\req\req_set.py", line 428, in _check_skip_installed
    req_to_install, upgrade_allowed)
  File "C:\Users\csprock\Anaconda3\lib\site-packages\pip\index.py", line 465, in find_requirement
    all_candidates = self.find_all_candidates(req.name)
  File "C:\Users\csprock\Anaconda3\lib\site-packages\pip\index.py", line 423, in find_all_candidates
    for page in self._get_pages(url_locations, project_name):
  File "C:\Users\csprock\Anaconda3\lib\site-packages\pip\index.py", line 568, in _get_pages
    page = self._get_page(location)
  File "C:\Users\csprock\Anaconda3\lib\site-packages\pip\index.py", line 683, in _get_page
    return HTMLPage.get_page(link, session=self.session)
  File "C:\Users\csprock\Anaconda3\lib\site-packages\pip\index.py", line 811, in get_page
    inst = cls(resp.content, resp.url, resp.headers)
  File "C:\Users\csprock\Anaconda3\lib\site-packages\pip\index.py", line 731, in __init__
    namespaceHTMLElements=False,
TypeError: parse() got an unexpected keyword argument 'transport_encoding'

Any ideas? (this problem only started after I installed tensorflow) Thanks.


回答 0

我有同样的问题,对我有用的是用conda更新点子:

conda install pip

它将我的点值从9.0.1-py36hadba87b_3更改为9.0.1-py36h226ae91_4,并解决了问题。

I had the same problem and what worked for me was updating pip with conda:

conda install pip

It changed my pip from 9.0.1-py36hadba87b_3 to 9.0.1-py36h226ae91_4 and solved issue.


回答 1

下载https://github.com/html5lib/html5lib-python/tree/master/html5lib并覆盖tensorflow环境“ envs \ tensorflow \ Lib \ site-packages \ html5lib”中html5lib文件夹中的所有文件,那么您应该能够在那之后运行任何“ pip install”命令

download https://github.com/html5lib/html5lib-python/tree/master/html5lib and overwrite all the files within html5lib folder in your tensorflow environment “envs\tensorflow\Lib\site-packages\html5lib” Then you should be able to run any “pip install” commands after that


回答 2

我在最新版本的Anaconda 3上安装keras时遇到了相同的问题(使用pip安装tensorflow 1.3之后),我可以通过使用conda安装keras来解决此问题。 conda install -c conda-forge keras

I ran into the same problem while installing keras (after I installed tensorflow 1.3 using pip) on the latest version of Anaconda 3. I was able to fix the problem by installing keras using conda conda install -c conda-forge keras


回答 3

安装SerpentAI时出现此确切错误。我所做的所有修复工作都activate serpent在conda提示符下运行,然后再次运行命令。不知道它是否适用于您的情况,但它们似乎足够接近。

编辑-如果上述方法无效,请注释掉以下行:

这对我来说非常有效。(这花费了我们社区中一个有用的成员进行了8个小时的调试)

I was getting this exact error installing SerpentAI. All I did to fix it was run activate serpent in conda prompt and then I ran the command again. Not sure if it’s applicable to your situation, but they seem close enough that it might.

EDIT – if the above didn’t work, comment out this line:

That worked perfectly for me. (this took a helpful member of our community 8 hours to debug)


回答 4

这对我有用:

python -m pip install –upgrade张量流

This worked for me:

python -m pip install –upgrade tensorflow


回答 5

pip3 install -U html5lib=="0.9999999"

为我工作

这是github上的html5lib错误

来自:https : //stackoverflow.com/a/39087283

pip3 install -U html5lib=="0.9999999"

worked for me

here’s the html5lib bug on github

from: https://stackoverflow.com/a/39087283


回答 6

这是给我的解决方法:

cd /usr/share/python-wheels/

目录的内容:

-rwxrwxrwx   1 www-data www-data 493905 Jul 22  2015 html5lib-0.999-py2.py3-none-any.whl
-rw-r--r--   1 root     root     112620 Apr  3  2019 html5lib-0.999999999-py2.py3-none-any.whl

跑:

mv html5lib-0.999-py2.py3-none-any.whl html5lib-0.999-py2.py3-none-any.whl.bak

pip3工作正常。正在加载旧的0.999版本。

Here was the fix for me:

cd /usr/share/python-wheels/

Contents of dir:

-rwxrwxrwx   1 www-data www-data 493905 Jul 22  2015 html5lib-0.999-py2.py3-none-any.whl
-rw-r--r--   1 root     root     112620 Apr  3  2019 html5lib-0.999999999-py2.py3-none-any.whl

Run:

mv html5lib-0.999-py2.py3-none-any.whl html5lib-0.999-py2.py3-none-any.whl.bak

pip3 works fine after. Was loading the old 0.999 version.