pip throws TypeError: parse() got an unexpected keyword argument 'transport_encoding' when trying to install new packages

PythonPython 3.xPipAnaconda

Python Problem Overview


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.

Python Solutions


Solution 1 - Python

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.

Solution 2 - Python

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

Solution 3 - Python

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

Solution 4 - Python

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: enter image description here

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

Solution 5 - Python

This worked for me:

> python -m pip install --upgrade tensorflow

Solution 6 - Python

pip3 install -U html5lib=="0.9999999"

worked for me

here's the html5lib bug on github

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

Solution 7 - Python

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.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionthewayupView Question on Stackoverflow
Solution 1 - PythonThormerView Answer on Stackoverflow
Solution 2 - PythonRomeoView Answer on Stackoverflow
Solution 3 - PythonPeachView Answer on Stackoverflow
Solution 4 - PythonZimri LeisherView Answer on Stackoverflow
Solution 5 - Pythonuser3477889View Answer on Stackoverflow
Solution 6 - PythontgrrrView Answer on Stackoverflow
Solution 7 - PythonTLK3View Answer on Stackoverflow