Skip to content

Add support for micromamba environments #20919

Closed

Description

Type: Bug

Behaviour

Expected vs. Actual

I expect the python: conda path setting to be used everywhere conda is called.
As can be seen from the logs, a plain conda call is used many times, and something tries to find python installations under ~\Miniconda3\..., which does not exist.
This results in that no environments are found, and pylance cannot find locally installed packages.

Steps to reproduce:

  1. Uninstall conda if you have it.
  2. Install micromamba
  3. Set the conda path to point to micromamba

Diagnostic data

  • Python version (& distribution if applicable, e.g. Anaconda): 3.11.0
  • Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): Conda
  • Value of the python.languageServer setting: Pylance

Output for Python in the Output panel

User Settings


condaPath: "C:\Users\carl4189\micromamba\condabin\micromamba.bat"

languageServer: "Pylance"

linting
• flake8Args: "<placeholder>"
• flake8Enabled: true
• pycodestyleArgs: "<placeholder>"
• pycodestyleEnabled: true
• pydocstyleEnabled: true

terminal
• activateEnvironment: false

Extension version: 2023.5.10791008
VS Code version: Code 1.76.2 (ee2b180d582a7f601fa6ecfdad8d9fd269ab1884, 2023-03-14T17:55:54.936Z)
OS version: Windows_NT x64 10.0.19044
Modes:
Sandboxed: No

System Info
Item Value
CPUs Intel(R) Core(TM) i5-10210U CPU @ 1.60GHz (8 x 2112)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_renderer: enabled_on
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: disabled_off
Load (avg) undefined
Memory (System) 15.78GB (6.73GB free)
Process Argv
Screen Reader no
VM 0%

Activity

  1. karrtikr commented on Mar 27, 2023

    @karrtikr

    Thanks for the bug report! We just wanted to quickly acknowledge we received it and we will triage this as soon as we can.

  2. psobolewskiPhD commented on Apr 5, 2023

    @psobolewskiPhD

    Would love to see this work. Mamba works, because conda is still present. But micromamba doesn't have a base env with conda.

  3. changed the title [-]Using micromamba instead of conda[/-] [+]Improve micromamba support[/+] on May 8, 2023
  4. karrtikr commented on May 8, 2023

    @karrtikr

    Turning this into a feature request as we currently don't support micromamba, to resolve this we need to support identifying micromamba version correctly.

    Currently if version is below 4.7, we do not use conda/micromamba run, so environment is not activated before it is used leading to import errors.

  5. removed their assignment
    on May 8, 2023
  6. github-actions commented on May 8, 2023

    @github-actions

    Thanks for the feature request! We are going to give the community 60 days from when this issue was created to provide 7 👍 upvotes on the opening comment to gauge general interest in this idea. If there's enough upvotes then we will consider this feature request in our future planning. If there's unfortunately not enough upvotes then we will close this issue.

  7. changed the title [-]Improve micromamba support[/-] [+]Improve micromamba support by allowing use of micromamba run where applicable[/+] on May 8, 2023
  8. CarlAndersson commented on May 11, 2023

    @CarlAndersson
    Author

    micromamba run exists at least in micromamba version 1.0.0. The changelog indicates that is has existed since version 0.21.0.
    The output from conda info --json and micromamba info --json might be a good place to find out if the command is conda or mircomamba without resorting to inspecting the command name. E.g., conda info --json has a 'conda_version', while micromamba info --json has a 'micromamba version'.
    Let me know if there's anything more I can do to assist!

  9. brettcannon commented on May 25, 2023

    @brettcannon
    Member

    Thank you to everyone who upvoted this issue! Since the community showed interest in this feature request we will leave this issue open as something to consider implementing at some point in the future.

    We do encourage people to continue 👍 the first/opening comment as it helps us prioritize our work based on what the community seems to want the most.

  10. 22 remaining items

  11. stessaris commented on Feb 9, 2024

    @stessaris

    On unix based systems I'm using direnv with this direnv vscode extension. It has the advantage that works with any backend, e.g. nix, or more complex setups; e.g., in some projects I layer a conda environment on top of a nix shell. I guess that it should work with Windows as well, but I never tried it.

    To use micromamba you could modify the default anaconda layout by changing the command "$conda" shell.bash activate "$env_loc" to "${MAMBA}" shell activate -s bash -p "${env_loc}" in the eval command.

    In alternative, you can use your own shell script. E.g. I use something like this (it'd be better refactored into a function, though):

    MAMBA="$(command -v micromamba)"
    JQ="$(command -v gojq || command -v jq)"
    
    CONDA_ENV_NAME=lab
    CONDA_ENV_YAML="${PWD}/environment.yml"
    
    env_loc="$("$MAMBA" env list  --json|"$JQ" -r --arg en ${CONDA_ENV_NAME} '.envs[]|select(endswith("/" + $en))')"
    
    if [ ! -d "${env_loc}" ]; then
        "${MAMBA}" env create --yes -n ${CONDA_ENV_NAME} -f "${CONDA_ENV_YAML}"
        env_loc="$("$MAMBA" env list  --json|"$JQ" -r --arg en ${CONDA_ENV_NAME} '.envs[]|select(endswith("/" + $en))')"
    fi
    
    eval "$("${MAMBA}" shell activate -s bash -p "${env_loc}")"
  12. specter119 commented on Apr 28, 2024

    @specter119

    Basic support

    • Add support for correctly identifying version for micromamba
    • Make sure micromamba envs are automatically discovered
    • Add micromamba run support
    • Add ability to support adding custom path to micromamba

    Kartik Raj (@kartikrajjj) any update now?

  13. Misaka-No-10032 commented on May 2, 2024

    @Misaka-No-10032

    I figured it out in this way:

    1. Create a file named activate in the same folder as your micromamba executable.
    2. Paste the following content into the file (replace with the MAMBA_ROOT_PREFIX on your machine):
    #!/bin/sh
    _MAMBA_ROOT="<YOUR MAMBA_ROOT_PREFIX>"
    # Copyright (C) 2012 Anaconda, Inc
    # SPDX-License-Identifier: BSD-3-Clause
    \. "$_MAMBA_ROOT/etc/profile.d/micromamba.sh" || return $?
    micromamba activate "$@"
    
    1. Add execute permission to the file.
    2. In VS Code, open settings and find python.condaPath, set the value to the path of your micromamba executable.
    3. Set python.venvPath to <YOUR MAMBA_ROOT_PREFIX>/envs/

    With these steps, VS Code should be able to identify and activate micromamba environments.

    Note that micromamba run won't work with the Python extension because the extension checks the availability of conda run based on the conda version (conda info). Since our micromamba executable replaces conda, micromamba info returns the version 1.5.8. As a result, conda <= 4.12.x does not support conda run. Therefore, the extension assumes that conda run is not available.

  14. suimong commented on May 31, 2024

    @suimong

    Here's my workaround: https://github.com/suimong/micromamba-vscode-compat

    Looking at the source code, I believe the key incompability between micromamba and conda that this extension cares about is the output from conda info --json. the keys of the output json from micromamba info --json is completely different from conda info --json, therefore it is impossible for vscode-python to extract any information from that json output. The solution is a making a shell script as the micromamba wrapper, which modifies the keys of micromamba info --json before sending to stdout.

    After this pr lands, micromamba will be able to output conda compatible info --json and vscode should be trivially able to support micromamba.

  15. Misaka-No-10032 commented on Jun 2, 2024

    @Misaka-No-10032

    Here's my workaround: https://github.com/suimong/micromamba-vscode-compat

    Looking at the source code, I believe the key incompability between micromamba and conda that this extension cares about is the output from conda info --json. the keys of the output json from micromamba info --json is completely different from conda info --json, therefore it is impossible for vscode-python to extract any information from that json output. The solution is a making a shell script as the micromamba wrapper, which modifies the keys of micromamba info --json before sending to stdout.

    After this pr lands, micromamba will be able to output conda compatible info --json and vscode should be trivially able to support micromamba.

    You are right. I found a similar solution at https://github.com/jonashaag/micromamba-pycharm, but this one is implemented in Python.

  16. specter119 commented on Jun 11, 2024

    @specter119

    Karthik Nadig (@karthiknadig) can add somebody follow this issue?

    the behavior of micromamba is quite similar with conda currently.

  17. brettcannon commented on Jun 12, 2024

    @brettcannon
    Member

    We actively rewriting our discovery code (driven by Don Jayamanne (@DonJayamanne) ) as well as working towards an API to make so people can create an e.g. micromamba extension that feeds interpreter info to the extension (being driven by Karthik Nadig (@karthiknadig) ). There's no ETA on any of this, but do know that micromamba support will be possible at some point.

  18. liushapku commented on Aug 22, 2024

    @liushapku

    I figured it out in this way:

    1. Create a file named activate in the same folder as your micromamba executable.
    2. Paste the following content into the file (replace with the MAMBA_ROOT_PREFIX on your machine):
    #!/bin/sh
    _MAMBA_ROOT="<YOUR MAMBA_ROOT_PREFIX>"
    # Copyright (C) 2012 Anaconda, Inc
    # SPDX-License-Identifier: BSD-3-Clause
    \. "$_MAMBA_ROOT/etc/profile.d/micromamba.sh" || return $?
    micromamba activate "$@"
    
    1. Add execute permission to the file.
    2. In VS Code, open settings and find python.condaPath, set the value to the path of your micromamba executable.
    3. Set python.venvPath to <YOUR MAMBA_ROOT_PREFIX>/envs/

    With these steps, VS Code should be able to identify and activate micromamba environments.

    Note that micromamba run won't work with the Python extension because the extension checks the availability of conda run based on the conda version (conda info). Since our micromamba executable replaces conda, micromamba info returns the version 1.5.8. As a result, conda <= 4.12.x does not support conda run. Therefore, the extension assumes that conda run is not available.

    I confirmed this method works with the following change to the activate file:

    _MAMBA_EXEC=/path/to/micromamba/executable
    _MAMBA_ROOT="$HOME/micromamba"
    __mamba_setup="$(_MAMBA_EXEC --shell ${SHELL##*/} --root-prefix "${_MAMBA_ROOT}" 2> /dev/null)" || echo "activation failed" > $LOG
    eval "$__mamba_setup"
    micromamba activate "$@"
    
    1. I simply downloaded an micromamba executable and put it in one of the PATH. No etc/profile.d/micromamba.sh ever existed.
    2. The . should not be escaped to represent source
    3. the file activate should be put in the same dir as the executable. (Maybe It is also recommended to add deactivate)
    4. ${SHELL} is usually the full path like /usr/bin/bash, but micromamba only accepts bash.
    5. If fail to activate, check the LOG
  19. YouJiacheng commented on Sep 7, 2024

    @YouJiacheng

    Hey guys! I think we can just switch from micromamba to pixi.
    I think pixi is a better micromamba, and it has been supported by vscode-python since 9 Jul 2024!
    https://github.com/microsoft/vscode-python/releases/tag/v2024.10.0
    #22968

    Why pixi: https://prefix.dev/blog/pixi_a_fast_conda_alternative

    • Faster
      image
    • NO Activation Needed!
    • Native Support for Globally Installed tools -- NO base Environment Needed!
      • Each globally installed tool lives in its own isolated environment
    • Better PyPI dependencies Integration (uv!)

    Transitioning Guide: https://pixi.sh/latest/switching_from/conda/

  20. rkimura47 commented on Oct 8, 2024

    @rkimura47

    I figured out a version of Misaka-No-10032 and liushapku's method that worked for me on Windows using PowerShell as the default terminal. I haven't tested it extensively and the setup can probably be improved, but hopefully it can at least serve as a starting point. (Note: this requires PowerShell to be initialized with the hook installed by mamba shell init in your profile.)

    1. Move / copy the micromamba.exe executable file into the Scripts directory of your mamba root prefix, and rename it to conda.exe.
    2. In your PowerShell profile (likely in #region mamba initialize), modify the MAMBA_EXE environment variable to point to the path of the copied over conda.exe executable.
    #region mamba initialize
    # !! Contents within this block are managed by 'mamba shell init' !!
    $Env:MAMBA_ROOT_PREFIX = <YOUR MAMBA_ROOT_PREFIX>
    $Env:MAMBA_EXE = "<YOUR MAMBA_ROOT_PREFIX>\Scripts\conda.exe"
    (& $Env:MAMBA_EXE 'shell' 'hook' -s 'powershell' -r $Env:MAMBA_ROOT_PREFIX) | Out-String | Invoke-Expression
    #endregion
    
    1. In VS Code settings,
      1. set python.condaPath to the path of the copied over conda.exe executable.
      2. I didn't need to do this, but you may also want to set python.venvPath to <YOUR MAMBA_ROOT_PREFIX>/envs/.
  21. symzn commented on Oct 10, 2025

    @symzn

    Hello,
    I've developed a simple extension using the vscode-python-envs API that allows VS Code to discover and use your micromamba environments.
    This is my first time coding in TypeScript, so any feedback is welcome. It's tested on Windows but should work on Linux as well.

    You can find it on the Marketplace here:
    https://marketplace.visualstudio.com/items?itemName=symzn.vscode-micromamba-env
    https://github.com/symzn/vscode-micromamba-env
    Note: I am still using the micromamba 1.5.10. But as the extension only relies on MAMBA_ROOT_PREFIX env var value & ~/.conda/environments.txt, I assume that it shall work with newer version of micromamba

  22. symzn commented on Dec 5, 2025

    @symzn

    Hello,

    I wanted to follow up on my previous message.
    I apologize, but the extension I mentioned earlier (based on the ms-python-envs API) does not work properly yet.
    There are still pending issues with the Environment Provider API that need to be resolved before it can be fully operational.

    Since fixing these API issues might take some time, I decided to take a different, more straightforward approach.
    I have developed a new extension:

    Instead of relying on the Provider API, this new version works autonomously by:

    1. Detecting environments from environments.txt.
    2. Injecting the activated environment variables directly into the terminal.
    3. Generating a .env file and updating python.defaultInterpreterPath workspace settings for smooth integration.

    It is much more stable and is available now if anyone needs a temporary solution while waiting for the native API to mature.

    Note: I haven't had time to test it on Linux yet (I will do so ASAP), but I am quite confident that it will work or require very small adaptations.
    Update: minor fix since this message : extension works also on Linux (with bash)

  23. eleanorjboyd commented on Dec 8, 2025

    @eleanorjboyd
    Member

    Hello everyone! We are now moving to the cool, new Python Environments Extension for all things environments! From here anyone can create an extension to handle different environments like micromamba! Feel free to reach out via this repo if you want to contribute support! https://github.com/microsoft/vscode-python-environments

  24. removed
    needs spikeLabel for issues that need investigation before they can be worked on.
    on Dec 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-environmentsFeatures relating to handling interpreter environmentscommunity askFeature request that the community expressed interest infeature-requestRequest for new features or functionality

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions