Skip to content
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 %mamba magic to install packages in current kernel #14075

Closed
dshean opened this issue May 11, 2023 · 10 comments · Fixed by #14191
Closed

Add %mamba magic to install packages in current kernel #14075

dshean opened this issue May 11, 2023 · 10 comments · Fixed by #14191
Milestone

Comments

@dshean
Copy link

dshean commented May 11, 2023

          If you wish, you could define a `%mamba` magic similarly to how `%pip` and `%conda` are defined in #11524

Originally posted by @jakevdp in #9517 (comment)

@dshean
Copy link
Author

dshean commented May 11, 2023

This issue continues to come up for hub deployments with more complex environments. Just wanted to resurface a feature request for a %mamba magic.

@lizeidsness
Copy link

I wondered that too. This worked as a workaround:

%alias mamba conda
%mamba env list

@fecet
Copy link

fecet commented Jul 31, 2023

A mamba magic would be great but what's the problem of just using !mamba?

@mjkanji
Copy link

mjkanji commented Aug 7, 2023

A mamba magic would be great but what's the problem of just using !mamba?

According to the creator of IPython, directly calling the shell can result in unexpected behaviour with respect to which environment the packages are actually installed in. And see this SO post with more links/details.

@fecet
Copy link

fecet commented Aug 7, 2023

A mamba magic would be great but what's the problem of just using !mamba?

According to the creator of IPython, directly calling the shell can result in unexpected behaviour with respect to which environment the packages are actually installed in. And see this SO post with more links/details.

I think this was caused by the PATH environment is according to that one you open notebook instead of kernel, but that can be configured by kernelspec, I have a snippet for that:

    python -m ipykernel install --user --name $CONDA_DEFAULT_ENV --display-name "Python $(python-version) ($CONDA_DEFAULT_ENV)"
    json_file="$HOME/.local/share/jupyter/kernels/$CONDA_DEFAULT_ENV/kernel.json"
    # jq '. + {env: {PATH: env.PATH}}' $json_file > $json_file
    cat <<< $(jq '. + {env: {PATH: env.PATH}}' $json_file) > $json_file

I would like to crate a PR to add mamba magic but I doubt whether it will be accepted because there is a simple workaround (like this).

@dshean
Copy link
Author

dshean commented Aug 7, 2023

OK! I think there is still value in a PR for %mamba, which is simpler than the workaround you mention. The average new jupyter/ipython user won't understand nuances here.

@dshean
Copy link
Author

dshean commented Aug 7, 2023

Thanks @lizeidsness, though I'm not sure #14075 (comment) solves the underlying issue, as this should just run conda, not mamba, which offers improved performance over conda, esp for more complex environments.

@mjkanji
Copy link

mjkanji commented Aug 7, 2023

While we are considering this, it would also be great to have support for a %micromamba magic, which is a smaller, pure C++ implementation of mamba, that's also independent of conda (i.e., you don't need conda installed in your environment at all).

I do realize, though, that at some point, you just have to say no to these requests. Not to mention, the folks behind mamba and micromamba are now making yet another package manager called pixi: [ 1 ][ 2 ]

@lizeidsness
Copy link

lizeidsness commented Aug 8, 2023

@dshean

Thanks @lizeidsness, though I'm not sure #14075 (comment) solves the underlying issue, as this should just run conda, not mamba, which offers improved performance over conda, esp for more complex environments.

Noted - but was meant as a temporary workaround until it was maybe implemented.

@tsnow03
Copy link

tsnow03 commented Sep 19, 2023

%conda has become too cumbersome for certain installs. Switching to !mamba, but I hope that %mamba gets implemented at some point.

Carreau added a commit that referenced this issue Oct 1, 2023
Conda has two compatible alternative that are mamba and micromamba.

In order for users to be able to use conda environment based on these
two drop-in alternative, this patch implements two additional magic
commands that makes them usable in the same fashion as conda.

Fixes #14075
@Carreau Carreau added this to the 8.17 milestone Oct 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants