37

I updated anaconda using Anaconda Command Prompt.

After update whenever I run any command ex: conda info or conda list I get the below error

module 'brotli' has no attribute 'error'

I would Really appreciate any help on this! Not sure how it solve it

TigSh
  • 615
  • 1
  • 6
  • 15

9 Answers9

48

I solved this issue by commenting lines 376 & 377 in the file

C:\ProgramData\Anaconda3\Lib\site-packages\urllib3\response.py

enter image description here

and then install brotli library by running either

pip install brotli

or

conda install brotli

After successful installation, uncomment above lines. Do whatever you want now. Error should not come.

Community
  • 1
  • 1
Shrirang
  • 1,286
  • 10
  • 23
  • 3
    Your solution was the only one that worked for me with miniconda3. – Wall-E Jul 21 '21 at 18:57
  • I was facing the same issue. None of them worked. So I found this solution. – Shrirang Jul 22 '21 at 07:28
  • 2
    Just want to add that depending on the version, the line numbers may be different. I followed the error message `DECODER_ERROR_CLASSES += (brotli.error,) AttributeError: module 'brotli' has no attribute 'error'`, found the code, commented out this line and the "if" clause before this. For me this was line 390. – natnij Jan 05 '22 at 18:48
  • 1
    I ran into this today, but I don't use conda. This answer worked with a small modification (in Python 3.10.2, it's on line 390) `# DECODER_ERROR_CLASSES += (brotli.error,)\npass` – eatsfood Apr 20 '22 at 16:30
  • 2
    @Shrirang - Thanks you saved my day. My location is little bit different. On close analysis of the error message I am able to figure it out. Even though the other one is also present. I have to modify C:\ProgramData\Anaconda3\lib\site-packages\pip\_vendor\urllib3\response.py – Subramanian Aug 17 '22 at 13:47
  • @Subramanian Yeah. The location may have changed. I solved this 2 years ago. – Shrirang Aug 18 '22 at 11:55
  • I used a combination of this and kiran-parte's solution. 1. Commented the lines causing the error. The path was different for me since I am using a user install of miniconda. 2. `conda install -c conda-forge brotlipy` 3. Uncommented the lines causing the error. – jkonkle Jun 05 '23 at 18:22
33

I solved the issue by installing urllib3

Just open the terminal and type:

conda install -c anaconda urllib3

or you can also try:

conda install -c conda-forge brotlipy
xKobalt
  • 1,498
  • 2
  • 13
  • 19
kiran-parte
  • 431
  • 3
  • 2
  • 4
    `conda install -c conda-forge brotlipy` worked for me when `conda install brotli` did not – Brian Mar 18 '21 at 16:12
10

I solved the issue by installing brotlipy

Just open the terminal and type:

conda install -c anaconda brotlipy
Sravan v J
  • 101
  • 1
  • 3
3

the commands below works for me somehow:

pip install -U urllib3
pip install -U brotlipy
dli
  • 1,173
  • 3
  • 14
  • 21
3

Yet another variation on a fix: for me (Windows 10, minconda3), installing brotli via pip fixed the problem.

Since I could not use any of these conda commands (list, update, install), the solution had to come from pip! Even though the error message pointed to urllib3, I first reinstalled brotli with pip, then performed my initial conda list command flawlessly... so I did not update or modify urllib3 in any way, which is kind of strange!

MCC
  • 109
  • 1
  • 5
  • 1
    I have the same setup (Win10/miniforge) and this did *not* fix the issue for me. `pip install brotli` worked, but did not fix the error. all of the other solutions listed return the same error as OP when run. – Evan Jun 15 '23 at 17:30
2

I solved this problem by the following way

1- comment the lines 
2- conda install brotli
3- run anaconda like normal 

i kept the lines 376 and 377 commented

RTS
  • 21
  • 1
1

I faced the same issue, but I was able to fix it by simply installing brotli.

conda install brotli

Brotli v1.0.7 fixed the problem for me.

  • 7
    This didn't help me. I get the same error (`module 'brotli' has no attribute 'error'`) when running `conda install brotli`. Furthermore, no change after successfully running `pip install brotli`. – Daddy32 May 28 '20 at 09:10
0

I did the following:

  1. commented out the recommended lines above.
  2. launched the anaconda navigator
  3. searched for any packages with "brotli"
  4. installed / updated all of those
  5. uncommented out the lines

Navigator is back working but not sure of any other downstream issues yet.

skillsmuggler
  • 1,862
  • 1
  • 11
  • 16
-2

I solved this issue by commenting lines 389 & 390 in the file

C:\Users\(user)\AppData\Roaming\Python\Python36\site-packages\urllib3\response.py

and then install brotli library by running

pip install brotli
C. Peck
  • 3,641
  • 3
  • 19
  • 36