96

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.

6
  • 3
    Got the same problem Sep 30, 2017 at 7:21
  • 3
    Does conda install work?
    – rostamn739
    Sep 30, 2017 at 9:17
  • 15
    Also, this problem only started after installing TensorFlow.
    – thewayup
    Sep 30, 2017 at 18:00
  • 6
    me too. win 10 and Anaconda 3
    – jef
    Oct 1, 2017 at 4:57
  • 3
    I can confirm it happened for me after installing Tensorflow on Anaconda 3 for Windows 10. Installed a bunch of plugins, then after Tensorflow couldn't install any more.
    – Omegastick
    Oct 3, 2017 at 0:57

7 Answers 7

196

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.

8
  • Worked for me too. Thank you. In my case Info was like this: The following packages will be SUPERSEDED by a higher-priority channel: pip: 9.0.1-py36hadba87b_3 --> 9.0.1-py36_0 conda-forge Dec 15, 2017 at 13:19
  • I had the same problem, like the 6 above, this worked for me as well. Dec 19, 2017 at 15:41
  • Mine is already on py35h691316f_4 and this command is not changing anything. I'm still getting the exception. Dec 29, 2017 at 11:35
  • This worked for me: python -m pip install --upgrade tensorflow Dec 29, 2017 at 11:48
  • Awesome. It worked. The problem was with tensorflow and pip co-existence.
    – Jyotirmay
    Jan 15, 2018 at 13:25
29

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

4
  • 45
    Piggybacking on Romeo's answer, conda install --force html5lib fixed the problem for me. Oct 8, 2017 at 21:22
  • tried this for both tensorflow and tensorflow-gpu and doesnt traceback error remains exactly the same: File "C:\Users\Administrator\Anaconda3\lib\site-packages\pip\index.py", line 731, in init namespaceHTMLElements=False, TypeError: parse() got an unexpected keyword argument 'transport_encoding
    – nights
    Oct 16, 2017 at 8:32
  • ok got it working. so its not the tensorflows install that you should replace but your anaconda3 html5lib -> \Anaconda3\Lib\site-packages\html5lib . this made it work for me finally.
    – nights
    Oct 16, 2017 at 8:36
  • 5
    @MikeLanzetta solution did not work for me. conda install -c anaconda html5lib worked
    – Ravi
    Nov 2, 2017 at 6:41
10

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
  • This does not work for me, Win 10 Anaconda 5.0.0 python 3.6 tensorflow 1.3 cuda 8 and cudnn 6 Oct 6, 2017 at 17:55
  • Looks like you're installing the tensorflow gpu version, not sure that would work with Anaconda.
    – Peach
    Oct 7, 2017 at 18:28
  • doesnt work for me either. on keras 2.0.6 py36_0 conda-forge
    – nights
    Oct 16, 2017 at 8:29
7

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)

3
  • what is "activate"? I don't see that as a listed conda command.
    – thewayup
    Oct 2, 2017 at 1:03
  • it is to use a virtual environment created from [conda] (conda.io/docs/user-guide/tasks/manage-environments.html)
    – Ashniu123
    Oct 6, 2017 at 17:49
  • 1
    On manjaro linux, the file is located /usr/lib/python2.7/site-packages/pip/_internal/index.py , commented same line. Now works prefectly
    – ALLSYED
    Jun 12, 2018 at 7:47
1

This worked for me:

python -m pip install --upgrade tensorflow

0
pip3 install -U html5lib=="0.9999999"

worked for me

here's the html5lib bug on github

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

0

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.

Not the answer you're looking for? Browse other questions tagged or ask your own question.