Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use micromamba virtual environment in VS Code

We have to use micromamba for our app because conda is prohibitively slow for installing our packages. We use a devcontainer to install micromamba and its packages. This works for the VS Code terminal but the editor still cannot find my packages.

I only see a way to activate the micromamba environment with a shell script snippet or shell rc file. The works for the terminal, but I dont see a way to activate it for the editor processes. The closest setting I found is specific to venvs.

like image 266
twinlakes Avatar asked May 18 '26 12:05

twinlakes


2 Answers

Another way to do this is to use the micromamba extension for VS Code. It will allow you to activate existing Mamba environments or create new ones: https://github.com/mamba-org/vscode-micromamba
To install it, go to the extensions tab in VS Code and search for Mamba.

like image 127
Tom F Avatar answered May 20 '26 01:05

Tom F


If you don't want to install any extensions, what I use to do is the following:

  1. In a terminal where the mamba environment is activated, type "which python", this gives you the path to the python that is used.

  2. Open the VS Code command palette (Ctrl+Shift+P).

  3. Choose "Python: Select Interpreter".

  4. If the correct python isn't listed, select "Enter interpreter path".

  5. Then enter the path you got in step 1) or choose it by browsing your files.

The next time you run your script using either "Run Python File" or "Python Debugger: Debug Python File", it should use the correct mamba environment.

like image 23
Celmisia Avatar answered May 20 '26 02:05

Celmisia