Miniconda - Channel conda-forge not working - Traceback message

I have installed Miniconda on my Windows 10 PC. I have followed the Data Science book by Wes McKinney. I did everything 1:1 like this. I have then added conda-forge as a channel and also provided it with “strict”.

(base) $ conda config --add channels conda-forge
(base) $ conda config --set channel_priority strict

I then executed conda update conda in the base environment and installed everything. Then when I typed conda list, I got a weird message with “traceback” in “Anaconda Promt”. Also other commands like conda --version did not work without such a message. I searched for solutions but only found old amounts where either Conda was old or it was a bug from Conda. The only solution that worked for me was to reinstall Miniconda. However, whenever I added conda-forge and did an update, it broke.

I also tried running conda update --all. Without success. I also updated everything via the default channel first and then added conda-forge. Did not work either. I also tried different sequences of this process. Without success.

Otherwise I haven’t changed anything and this error only ever occurs when I add conda-forge as a channel. The version I installed is the current one:
Latest - Conda 23.3.1 Python 3.10.10 released April 24, 2023
But as you know, I also updated it via Conda when I tried it. But there also came out this message.

Here’s what I get out of it:

(base) C:\Users\Name>conda list
Traceback (most recent call last):
  File "C:\Users\Name\miniconda3\lib\site-packages\conda\exception_handler.py", line 16, in __call__
    return func(*args, **kwargs)
  File "C:\Users\Name\miniconda3\lib\site-packages\conda\cli\main.py", line 70, in main_subshell
    p = generate_parser()
  File "C:\Users\Name\miniconda3\lib\site-packages\conda\cli\conda_argparse.py", line 65, in generate_parser
    p = ArgumentParser(
  File "C:\Users\Name\miniconda3\lib\site-packages\conda\cli\conda_argparse.py", line 152, in __init__
    self._subcommands = context.plugin_manager.get_hook_results("subcommands")
  File "C:\Users\Name\miniconda3\lib\site-packages\conda\base\context.py", line 502, in plugin_manager
    from ..plugins.manager import get_plugin_manager
  File "C:\Users\Name\miniconda3\lib\site-packages\conda\plugins\__init__.py", line 3, in <module>
    from .hookspec import hookimpl  # noqa: F401
  File "C:\Users\Name\miniconda3\lib\site-packages\conda\plugins\hookspec.py", line 9, in <module>
    from .types import CondaSolver, CondaSubcommand, CondaVirtualPackage
  File "C:\Users\Name\miniconda3\lib\site-packages\conda\plugins\types.py", line 7, in <module>
    from ..core.solve import Solver
  File "C:\Users\Name\miniconda3\lib\site-packages\conda\core\solve.py", line 41, in <module>
    from .index import _supplement_index_with_system, get_reduced_index
  File "C:\Users\Name\miniconda3\lib\site-packages\conda\core\index.py", line 22, in <module>
    from .package_cache_data import PackageCacheData
  File "C:\Users\Name\miniconda3\lib\site-packages\conda\core\package_cache_data.py", line 56, in <module>
    from .path_actions import CacheUrlAction, ExtractPackageAction
  File "C:\Users\Name\miniconda3\lib\site-packages\conda\core\path_actions.py", line 35, in <module>
    from ..gateways.connection.download import download
  File "C:\Users\Name\miniconda3\lib\site-packages\conda\gateways\connection\__init__.py", line 4, in <module>
    from requests import ConnectionError, HTTPError, Session
  File "C:\Users\Name\miniconda3\lib\site-packages\requests\__init__.py", line 43, in <module>
    import urllib3
  File "C:\Users\Name\miniconda3\lib\site-packages\urllib3\__init__.py", line 17, in <module>
    from .connectionpool import HTTPConnectionPool, HTTPSConnectionPool, connection_from_url
  File "C:\Users\Name\miniconda3\lib\site-packages\urllib3\connectionpool.py", line 14, in <module>
    from ._request_methods import RequestMethods
  File "C:\Users\Name\miniconda3\lib\site-packages\urllib3\_request_methods.py", line 10, in <module>
    from .response import BaseHTTPResponse
  File "C:\Users\Name\miniconda3\lib\site-packages\urllib3\response.py", line 277, in <module>
    class BaseHTTPResponse(io.IOBase):
  File "C:\Users\Name\miniconda3\lib\site-packages\urllib3\response.py", line 287, in BaseHTTPResponse
    DECODER_ERROR_CLASSES += (brotli.error,)
AttributeError: module 'brotli' has no attribute 'error'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\Name\miniconda3\Scripts\conda-script.py", line 12, in <module>
    sys.exit(main())
  File "C:\Users\Name\miniconda3\lib\site-packages\conda\cli\main.py", line 129, in main
    return conda_exception_handler(main, *args, **kwargs)
  File "C:\Users\Name\miniconda3\lib\site-packages\conda\exception_handler.py", line 376, in conda_exception_handler
    return_value = exception_handler(func, *args, **kwargs)
  File "C:\Users\Name\miniconda3\lib\site-packages\conda\exception_handler.py", line 19, in __call__
    return self.handle_exception(exc_val, exc_tb)
  File "C:\Users\Name\miniconda3\lib\site-packages\conda\exception_handler.py", line 75, in handle_exception
    return self.handle_unexpected_exception(exc_val, exc_tb)
  File "C:\Users\Name\miniconda3\lib\site-packages\conda\exception_handler.py", line 88, in handle_unexpected_exception
    self.print_unexpected_error_report(error_report)
  File "C:\Users\Name\miniconda3\lib\site-packages\conda\exception_handler.py", line 159, in print_unexpected_error_report
    from .cli.main_info import get_env_vars_str, get_main_info_str
  File "C:\Users\Name\miniconda3\lib\site-packages\conda\cli\main_info.py", line 15, in <module>
    from ..core.index import _supplement_index_with_system
  File "C:\Users\Name\miniconda3\lib\site-packages\conda\core\index.py", line 22, in <module>
    from .package_cache_data import PackageCacheData
  File "C:\Users\Name\miniconda3\lib\site-packages\conda\core\package_cache_data.py", line 56, in <module>
    from .path_actions import CacheUrlAction, ExtractPackageAction
  File "C:\Users\Name\miniconda3\lib\site-packages\conda\core\path_actions.py", line 35, in <module>
    from ..gateways.connection.download import download
  File "C:\Users\Name\miniconda3\lib\site-packages\conda\gateways\connection\__init__.py", line 4, in <module>
    from requests import ConnectionError, HTTPError, Session
  File "C:\Users\Name\miniconda3\lib\site-packages\requests\__init__.py", line 43, in <module>
    import urllib3
  File "C:\Users\Name\miniconda3\lib\site-packages\urllib3\__init__.py", line 17, in <module>
    from .connectionpool import HTTPConnectionPool, HTTPSConnectionPool, connection_from_url
  File "C:\Users\Name\miniconda3\lib\site-packages\urllib3\connectionpool.py", line 14, in <module>
    from ._request_methods import RequestMethods
  File "C:\Users\Name\miniconda3\lib\site-packages\urllib3\_request_methods.py", line 10, in <module>
    from .response import BaseHTTPResponse
  File "C:\Users\Name\miniconda3\lib\site-packages\urllib3\response.py", line 277, in <module>
    class BaseHTTPResponse(io.IOBase):
  File "C:\Users\Name\miniconda3\lib\site-packages\urllib3\response.py", line 287, in BaseHTTPResponse
    DECODER_ERROR_CLASSES += (brotli.error,)
AttributeError: module 'brotli' has no attribute 'error'

(base) C:\Users\Name>conda list
Traceback (most recent call last):
  File "C:\Users\Name\miniconda3\lib\site-packages\conda\exception_handler.py", line 16, in __call__
    return func(*args, **kwargs)
  File "C:\Users\Name\miniconda3\lib\site-packages\conda\cli\main.py", line 70, in main_subshell
    p = generate_parser()
  File "C:\Users\Name\miniconda3\lib\site-packages\conda\cli\conda_argparse.py", line 65, in generate_parser
    p = ArgumentParser(
  File "C:\Users\Name\miniconda3\lib\site-packages\conda\cli\conda_argparse.py", line 152, in __init__
    self._subcommands = context.plugin_manager.get_hook_results("subcommands")
  File "C:\Users\Name\miniconda3\lib\site-packages\conda\base\context.py", line 502, in plugin_manager
    from ..plugins.manager import get_plugin_manager
  File "C:\Users\Name\miniconda3\lib\site-packages\conda\plugins\__init__.py", line 3, in <module>
    from .hookspec import hookimpl  # noqa: F401
  File "C:\Users\Name\miniconda3\lib\site-packages\conda\plugins\hookspec.py", line 9, in <module>
    from .types import CondaSolver, CondaSubcommand, CondaVirtualPackage
  File "C:\Users\Name\miniconda3\lib\site-packages\conda\plugins\types.py", line 7, in <module>
    from ..core.solve import Solver
  File "C:\Users\Name\miniconda3\lib\site-packages\conda\core\solve.py", line 41, in <module>
    from .index import _supplement_index_with_system, get_reduced_index
  File "C:\Users\Name\miniconda3\lib\site-packages\conda\core\index.py", line 22, in <module>
    from .package_cache_data import PackageCacheData
  File "C:\Users\Name\miniconda3\lib\site-packages\conda\core\package_cache_data.py", line 56, in <module>
    from .path_actions import CacheUrlAction, ExtractPackageAction
  File "C:\Users\Name\miniconda3\lib\site-packages\conda\core\path_actions.py", line 35, in <module>
    from ..gateways.connection.download import download
  File "C:\Users\Name\miniconda3\lib\site-packages\conda\gateways\connection\__init__.py", line 4, in <module>
    from requests import ConnectionError, HTTPError, Session
  File "C:\Users\Name\miniconda3\lib\site-packages\requests\__init__.py", line 43, in <module>
    import urllib3
  File "C:\Users\Name\miniconda3\lib\site-packages\urllib3\__init__.py", line 17, in <module>
    from .connectionpool import HTTPConnectionPool, HTTPSConnectionPool, connection_from_url
  File "C:\Users\Name\miniconda3\lib\site-packages\urllib3\connectionpool.py", line 14, in <module>
    from ._request_methods import RequestMethods
  File "C:\Users\Name\miniconda3\lib\site-packages\urllib3\_request_methods.py", line 10, in <module>
    from .response import BaseHTTPResponse
  File "C:\Users\Name\miniconda3\lib\site-packages\urllib3\response.py", line 277, in <module>
    class BaseHTTPResponse(io.IOBase):
  File "C:\Users\Name\miniconda3\lib\site-packages\urllib3\response.py", line 287, in BaseHTTPResponse
    DECODER_ERROR_CLASSES += (brotli.error,)
AttributeError: module 'brotli' has no attribute 'error'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\Name\miniconda3\Scripts\conda-script.py", line 12, in <module>
    sys.exit(main())
  File "C:\Users\Name\miniconda3\lib\site-packages\conda\cli\main.py", line 129, in main
    return conda_exception_handler(main, *args, **kwargs)
  File "C:\Users\Name\miniconda3\lib\site-packages\conda\exception_handler.py", line 376, in conda_exception_handler
    return_value = exception_handler(func, *args, **kwargs)
  File "C:\Users\Name\miniconda3\lib\site-packages\conda\exception_handler.py", line 19, in __call__
    return self.handle_exception(exc_val, exc_tb)
  File "C:\Users\Name\miniconda3\lib\site-packages\conda\exception_handler.py", line 75, in handle_exception
    return self.handle_unexpected_exception(exc_val, exc_tb)
  File "C:\Users\Name\miniconda3\lib\site-packages\conda\exception_handler.py", line 88, in handle_unexpected_exception
    self.print_unexpected_error_report(error_report)
  File "C:\Users\Name\miniconda3\lib\site-packages\conda\exception_handler.py", line 159, in print_unexpected_error_report
    from .cli.main_info import get_env_vars_str, get_main_info_str
  File "C:\Users\Name\miniconda3\lib\site-packages\conda\cli\main_info.py", line 15, in <module>
    from ..core.index import _supplement_index_with_system
  File "C:\Users\Name\miniconda3\lib\site-packages\conda\core\index.py", line 22, in <module>
    from .package_cache_data import PackageCacheData
  File "C:\Users\Name\miniconda3\lib\site-packages\conda\core\package_cache_data.py", line 56, in <module>
    from .path_actions import CacheUrlAction, ExtractPackageAction
  File "C:\Users\Name\miniconda3\lib\site-packages\conda\core\path_actions.py", line 35, in <module>
    from ..gateways.connection.download import download
  File "C:\Users\Name\miniconda3\lib\site-packages\conda\gateways\connection\__init__.py", line 4, in <module>
    from requests import ConnectionError, HTTPError, Session
  File "C:\Users\Name\miniconda3\lib\site-packages\requests\__init__.py", line 43, in <module>
    import urllib3
  File "C:\Users\Name\miniconda3\lib\site-packages\urllib3\__init__.py", line 17, in <module>
    from .connectionpool import HTTPConnectionPool, HTTPSConnectionPool, connection_from_url
  File "C:\Users\Name\miniconda3\lib\site-packages\urllib3\connectionpool.py", line 14, in <module>
    from ._request_methods import RequestMethods
  File "C:\Users\Name\miniconda3\lib\site-packages\urllib3\_request_methods.py", line 10, in <module>
    from .response import BaseHTTPResponse
  File "C:\Users\Name\miniconda3\lib\site-packages\urllib3\response.py", line 277, in <module>
    class BaseHTTPResponse(io.IOBase):
  File "C:\Users\Name\miniconda3\lib\site-packages\urllib3\response.py", line 287, in BaseHTTPResponse
    DECODER_ERROR_CLASSES += (brotli.error,)
AttributeError: module 'brotli' has no attribute 'error'

(base) C:\Users\Name>

It’s surprising to me that that book advises to set conda-forge as default globally like that. My understanding is that adding conda-forge to the base environment in a regular miniconda environment can be risky. If you want to use conda-forge for everything, better to install miniforge or mambaforge. Or, if you use regular miniconda, you can still use conda-forge, just don’t use it in the base environment. Perhaps someone more knowledgeable can give better advice.

It could be that the error is due to some incompatibility in library versions that wasn’t adequately foreseen (that is, a library broke backward compatibility in an unanticipated way and caused cascading breakage in other libs). If that’s the case, it may be resolved within a few weeks. I have no idea whether this is what’s happening for this particular situation, but I mention it because I’ve encountered such situations in the past.

1 Like

Installing conda-forge in Base is also recommended by the official website, isn’t it?

https://conda-forge.org/docs/user/introduction.html#how-can-i-install-packages-from-conda-forge

Because, I also tested the change of the channel in a virtual environment. But this still reset the channel globally.
You can read the instructions of the book here:

The problem is trying to replace the base packages from defaults with the conda-forge ones. You should be OK if you keep following the book instructions and create a fresh environment. Or, like @BrenBarn mentioned above, use miniforge from the start. Note that miniforge probably did not exist when those book instructions were written.

I have now also tried Miniforge. However, I get the same problem when I do conda update conda. And also update the list then. If I then enter conda list, the error comes again.

Unfortunately the issue in github was closed with the hint of a workaround. Why is not working on the solution of the problem, but only referred to a workaround? No one should have to work in the files of conda, I think.

And about the book: The last edition was published last year. It could have been updated then. Or on their own website, which the author also mentioned that he wants to do.