Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VSCode conda activate base giving CommandNotFoundError

I have Anaconda and Visual Studio Code installed on my computer. My default terminal for VS Code is Git Bash. When I open a new terminal in VSCode, it immediately runs the following commands:

C:/Users/ethan/AppData/Local/Continuum/anaconda3/Scripts/activate
conda activate base

The second of these commands gives the following error:

CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'.
If using 'conda activate' from a batch script, change your
invocation to 'CALL conda.bat activate'.

I have tried running conda init bash and conda init --all both inside the VSCode terminal, and inside Git Bash. It handles that command fine, but it doesn't solve my problem. I don't know if the second line of the error applies to me, but even if it did, I don't know how to change the command being called because it is done automatically by VSCode. This error occurs every time I launch a terminal in VSCode (even if I don't have any python files present in my workspace), and it happens both when I launch VSCode from the launch button in Anaconda Navigator and when I launch VSCode by itself.

like image 312
embradley Avatar asked Jun 04 '19 06:06

embradley


People also ask

How do you activate a conda base?

To activate your Conda environment, type source activate <yourenvironmentname> . Note that conda activate will not work on Discovery with this version. To install a specific package, type conda install -n <yourenvironmentname> [package] . To deactivate the current, active Conda environment, type conda deactivate .


3 Answers

I had the same issue. For me, easily resolved by launching VSC from the conda window.

Specifically, open your cmd prompt (for me, Anaconda Prompt), activate the environment using 'conda activate [envname]'. Then just run the command 'code'. This will launch VS Code with the activated environment and associated variables. From there, the debug works as expected.

like image 100
carl Avatar answered Oct 20 '22 02:10

carl


I had the same issue, I've fixed it by adding the Python.CondaPath in settings. Press Ctrl + Shift + P and select Terminal Configuration. Search for python.conda, and paste your conda path for example. C:\ProgramData\Anaconda3\Scripts\conda.exe

This will fix your issue.

enter image description here

like image 9
Ali Asad Avatar answered Oct 20 '22 04:10

Ali Asad


In VS code settings, search for "terminal.integrated.shellArgs.windows", then click "Edit in settings.json". For me, this opened "%APPDATA%\Code\User\settings.json". I set "terminal.integrated.shellArgs.windows": "-i -l" and this fixed it for me. My file:

{
    "terminal.integrated.shell.windows": "C:\\Program Files\\Git\\bin\\bash.exe",
    "terminal.integrated.shellArgs.windows": "-i -l"
}
like image 2
Justin Harris Avatar answered Oct 20 '22 04:10

Justin Harris