Error when trying to use conda on vs code: conda : The term 'conda' is not recognized as the name of a cmdlet

Viewed 13348

I am trying to build a basic machine learning algorithm, and to do so I am using the anaconda interpreter for python. However, even though visual studio code appears to have recognized conda as the interpreter, and I have the anaconda3 shell working as a separate application, I cannot get conda to work on vs code. Whenever I try to check for conda, I get the following error:

conda : The term 'conda' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ conda activate base
+ ~~~~~
    + CategoryInfo          : ObjectNotFound: (conda:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

I have tried the fixes linked here: 'Conda' is not recognized as internal or external command

however, they did not work for me. I tried setting conda to my path yet I still got the same error. Thanks in advance!

2 Answers

Try the following:

  1. Run Anaconda/Miniconda
  2. Activate the environment there:
conda activate your-env
  1. Start Visual Studio Code from the Anaconda/Miniconda terminal:
code

enter image description here

Then Visual Studio Code should recognize conda: enter image description here

To get python, anaconda, and conda to work well with VS Code I installed the Python extension.

Then in the Python extension settings, set the Python: Conda Path to your conda.exe and the 'Python: Default Interpreter Path to your python.exe.

For me the conda.exe path was in ...\Anaconda3\Library\Scripts\conda.exe and the 'python.exewas the conda base env one at...\Anaconda3\python.exe`

Related