Windows: configure VS Code integrated bash shell for Anaconda


So you’re / you’ve-been using Python in Windows. You know your way around setting up PATH variable so that you type “python” in your command prompt and it works. Now, say that you want to use Anaconda Python in bash. Let’s go one step further and say, you want to use the bash from your Visual Studio Code integrated shell. The process isn’t too different. There doesn’t seem to exist a guide, which covers all these together – hence this post.

My goal is to show you one of the possible ways to configure your development environment quickly – to you get you going in no time.

At the end you should have the following:

  • Bash shell working with python and,
  • Visual studio shell integration (optional)

Install & configure bash for Python:

  1. Optional step. Using Anaconda Prompt, I highly recommend that you create a new Anaconda environment if you don’t already have one. This page will
    show you how. I created a new environment “dev” using following command: conda create --no-default-packages -n dev python=2.7 – but that’s just me.
  2. Determine Python path. To find the Anaconda Python path – run following command in Anaconda Prompt: conda env list. Note down the path corresponding to dev environment. If you created dev environment in step 1, use the corresponding path. Just for your reference – it may or may not look like this: C:\Users\[user_name]\AppData\Local\Continuum\anaconda[version_number]\envs\dev.
  3. Got bash? If your command prompt does not have a $ sign, it is porbably not bash. If you’ve git bash or Atlassian SourceTree you’re good to go. The possible paths might be "C:\\Program Files\\Git\\bin\\bash.exe" for git bash or if you’ve got SourceTree, it could be at: "C:\\Users\\wildclick\\AppData\\Local\\Atlassian\\SourceTree\\git_local\\bin\\bash.exe" – look around on your computer drive. If not, I recommend installing git bash.
  4. Next step is to set up bash’s PATH variable, which is different than Window’s PATH variable. Switch to your git bash To see the current value of this variable run this command $ echo $PATH. Before going any further, make sure to back the current value – just in case if you need to rollback your changes. Now, you just have to append the path from step 2, by carefully executing:
    $export PATH="$PATH:/path/to/my/python/env"

    For me, I issued the following command: $export PATH="$PATH:/c/Users/wildclick/AppData/Local/Continuum/anaconda2/envs/dev". Be extra careful.

  5. Test. To test the change: I executed this command: $ python --version. And I got:
    Python 2.7.15 :: Anaconda, Inc.

Configure VS Code to use bash as default shell:

In settings.json (or Terminal > Integrated > Shell: Windows in the new user interface) set the bash path.

"terminal.integrated.shell.windows": "C:\\Users\\wildclick\\AppData\\Local\\Atlassian\\SourceTree\\git_local\\bin\\bash.exe"

VS code recommends, that you use bash.exe, and not something else like git-bash.exe. Using git-bash.exe might cause a separate window to open. Restart VS code, and start your terminal … bash awaits you!


Cheers! 🙂

Leave a Comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s