Activate a Conda Environment within VSCode terminal using Xonsh

1k Views Asked by At

Using xonsh as my shell and conda environments, I hit an error within the VSCode terminal when it attempts to activate an environment.

This is because VSCode issues the source activate environment command whenever the selected interpreter is a conda environment. That's correctly following the instructions from Anaconda and is discussed on https://github.com/Microsoft/vscode-python/issues/383

However, the Xonsh shell does things differently. It doesn't include a source command and instead has a plugin for managing conda environments (https://github.com/gforsyth/xonda). Within Xonsh, the correct command is conda activate environment

For the moment, I've created an alias for source as a workaround, but is there a better way? e.g. Is there some way to customise the command that's issued by VSCode?

1

There are 1 best solutions below

0
On

As shown in the question comments, the question asker has raised a Pull Request that will hopefully make this a non-issue in the future.

This answer is purely to highlight this information for future users and is marked community wiki to encourage future users to update this as and when more information comes to light.