mamba: ImportError: cannot import name 'init_std_stream_encoding' from 'conda.common.compat'

My mamba install was working fine till now when I suddenly get this today on any mamba command.

❯ mamba
Traceback (most recent call last):
  File "/home/user/miniconda3/bin/mamba", line 11, in <module>
    sys.exit(main())
  File "/home/user/miniconda3/lib/python3.9/site-packages/mamba/mamba.py", line 892, in main
    from conda.common.compat import ensure_text_type, init_std_stream_encoding
ImportError: cannot import name 'init_std_stream_encoding' from 'conda.common.compat' (/home/user/miniconda3/lib/python3.9/site-packages/conda/common/compat.py)

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 31
  • Comments: 29 (5 by maintainers)

Commits related to this issue

Most upvoted comments

I am also experiencing this issue. I keep my base environment stock (i.e., I don’t have any packages installed beyond what mambaforge comes with). I ran mamba update --all today and mamba is completely broken.

Edit:

For anyone stumbling upon this issue looking for a quick fix like I did, running conda install conda=4.12 in your base environment should do the trick for the time being.

conda uninstall mamba -y && conda clean -afy && conda install -c conda-forge mamba -y 

fixed it for me.

For anyone stumbling upon this issue looking for a quick fix like I did, running conda install conda=4.12 in your base environment should do the trick for the time being.

This worked for me only after conda remove mamba. Then, when I tried to reinstall mamba (conda install mamba -c conda-forge), I saw conda pulling in 4.13.0 again 😕

The trick then was conda install mamba conda=4.12.0 -c conda-forge.

I had this problem, too, so I updated mamba using conda:

#Name                    Version                   Build  Channel
libmamba                  0.23.3               hd8a31e3_1    conda-forge
libmambapy                0.23.3           py39hd55135b_1    conda-forge
mamba                     0.23.3           py39hfa8f2c8_1    conda-forge

Now, mamba no longer gives the “cannot import name ‘init_std_stream_encoding’” error, but it fails silently when running anything other than “mamba --version”.

If it matters, we’re running SMP Debian 5.10.113-1 (2022-04-29) x86_64 GNU/Linux

@Syzygianinfern0 you have the same old version of mamba, and the most recent conda version which breaks most mamba versions.

The previous conda and all mamba versions work fine. (conda 4.12 + mamba 0.23.3 for example).

I have added this repodata patch: https://github.com/conda-forge/conda-forge-repodata-patches-feedstock/pull/274 That should prevent this installation.

@maximlt if you start off from Miniforge or Mambaforge it would be more clean. We (conda-forge) cannot guarantee that mixing packages with defaults works.

I had this problem, too, so I updated mamba using conda:

#Name                    Version                   Build  Channel
libmamba                  0.23.3               hd8a31e3_1    conda-forge
libmambapy                0.23.3           py39hd55135b_1    conda-forge
mamba                     0.23.3           py39hfa8f2c8_1    conda-forge

Now, mamba no longer gives the “cannot import name ‘init_std_stream_encoding’” error, but it fails silently when running anything other than “mamba --version”.

If it matters, we’re running SMP Debian 5.10.113-1 (2022-04-29) x86_64 GNU/Linux

I can confirm this exact thing after I ran conda update mamba -c conda-forge. @wolfv