-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for micromamba environments #20919
Comments
Thanks for the bug report! We just wanted to quickly acknowledge we received it and we will triage this as soon as we can. |
Would love to see this work. Mamba works, because conda is still present. But micromamba doesn't have a base env with conda. |
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 |
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. |
|
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. |
Basic support
|
As a workaround: Create a file I would still very much appreciate if Micromamba were supported out of the box. |
It would be nice to support |
Didn't find it works, my current workaround is to set But still sometimes in notebooks, Pylance can not recognize environment for vscode intelligent after some period of time but the code can be properly run, I have to reload window every time I encountered this. |
So to actually get around this for This way, To recap:
This should provide a workaround/painless fix to the issue while VSCode devs sort this out more thoroughly. |
Hi, thanks for the alternatives. Test it on MacOS only but when I open a new terminal, So for others, if you failed at the aforementioned method, setting |
@richarddwang I should've specified that this is a fix on Linux using |
Thank you for this the walkaround. by the way if you are under windows and using PowerShell, you can add below line to the PS profile Set-Alias -name conda -value micromamba Dose the same thing, set alias for micromamba |
I will say we are aware that people want ways to have tools contribute to providing environments and interpreters, and we are thinking about a solution around this so extensions like https://marketplace.visualstudio.com/items?itemName=corker.vscode-micromamba could supply interpreter information. There is no ETA on that work, though, as we are tied up with other work for the foreseeable future. |
But wouldn't implementing this be rather straightforward? It already works with Anaconda which is a gargantuan toolset in comparison to micromamba (which relies on a single binary). In addition, micromamba (and mamba for that matter) are drop-ins for Anaconda. Anything Anaconda does, (micro)mamba does the same. There is already seems to be sufficient overlap if hacking together a solution works without the use of extensions... |
I realize it looks like it, but we are also talking about participating in our "Create Environment" command, etc., so it isn't as simple as it might look at first glance.
We would prefer not to use a hack to support (micro)mamaba and instead move everything (including Anaconda) to the new model for better, more thorough support and increase our test matrix (I realize mamba is meant to be a drop-in replacement, but if anything deviates we will be expected to support it, rightfully or not; for instance, micromamba's |
Maybe I am wrong but relying on possibly 3rd-party extensions for interpreter information seems at least as risky as expecting micromamba to conform to conda conventions. Or do MS intend to own the extensions for each supported interpreter? Would a (well-tested) "hack" from an external contributor be accepted in the interim, given there is no timeline on the long-term solution? |
I would rather not get into a design discussion here on the topic and wait until we open an issue on a proposed design.
We will have to think about it. We're discussing plans for 2024 right now, so depending how long we think things might take we could consider adding mamba and micromamba support with the caveat that it will probably move out. |
{
"python.venvPath": "<MAMBA_ROOT_PREFIX>/envs"
} can help vscode-python find environments. (I just found it out today).
For activation, I use profile as follows: Set-Alias -Name conda -Value micromamba
function activate {
(& $Env:MAMBA_EXE 'shell' 'hook' -s 'powershell' -p $Env:MAMBA_ROOT_PREFIX) | Out-String | Invoke-Expression
}
#region mamba initialize
# !! Contents within this block are managed by 'mamba shell init' !!
$Env:MAMBA_ROOT_PREFIX = "<MAMBA_ROOT_PREFIX>"
$Env:MAMBA_EXE = "<MAMBA_EXE>"
#(& $Env:MAMBA_EXE 'shell' 'hook' -s 'powershell' -p $Env:MAMBA_ROOT_PREFIX) | Out-String | Invoke-Expression
#endregion |
@YouJiacheng would you mind opening a bug for that? |
I would like to express support for this! |
Hey All, I cannot get this to work :/ Either the python extension complains that
even though it is initialized and works flawlessly in interactive shell sessions. It works to run python files though, as the interpreter path is used directly. Regards JD |
On unix based systems I'm using direnv with this direnv vscode extension. It has the advantage that works with any backend, e.g. To use 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}")" |
@kartikrajjj any update now? |
I figured it out in this way:
With these steps, VS Code should be able to identify and activate micromamba environments. Note that |
Here's my workaround: https://github.com/suimong/micromamba-vscode-compat Looking at the source code, I believe the key incompability between After this pr lands, micromamba will be able to output conda compatible |
You are right. I found a similar solution at https://github.com/jonashaag/micromamba-pycharm, but this one is implemented in Python. |
@karthiknadig can add somebody follow this issue? the behavior of micromamba is quite similar with conda currently. |
We actively rewriting our discovery code (driven by @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 @karthiknadig ). There's no ETA on any of this, but do know that micromamba support will be possible at some point. |
I confirmed this method works with the following change to the
|
Hey guys! I think we can just switch from Why
Transitioning Guide: https://pixi.sh/latest/switching_from/conda/ |
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
|
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:
Diagnostic data
python.languageServer
setting: PylanceOutput for
Python
in theOutput
panelUser Settings
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
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
The text was updated successfully, but these errors were encountered: