15
PS E:\Python and Data Science\PythonDatabase> conda activate base
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

PS E:\Python and Data Science\PythonDatabase> & C:/Users/Lenovo/Anaconda3/python.exe "e:/Python and Data Science/PythonDatabase/CourseHelper.py"
Hello World
PS E:\Python and Data Science\PythonDatabase> 
machnic
  • 2,304
  • 2
  • 17
  • 21
Vaibhav Bhavsar
  • 181
  • 2
  • 10

2 Answers2

24

You can set "python.terminal.activateEnvironment": false in your settings to deactivate activation of your environment. Alternatively, you can set "python.condaPath" to where conda exists so the extension can use conda appropriately.

Brett Cannon
  • 14,438
  • 3
  • 45
  • 40
  • 1
    Thanks! "Set "python.condaPath" to where conda exists so the extension can use conda appropriately." - This worked for me. To be more specific, go to vscode settings -> search "python.condaPath" -> you may see an empty box -> type conda path ( C:\Users\YourUserName\anaconda3\Scripts ) – Hassan Risvy Feb 23 '22 at 06:20
0

Building on @Brett Cannon's answer...

You have 2 options. Unless otherwise noted, all of the following assume you are changing VSCode Settings (F1 -> Terminal:Configure Terminal Settings).

Option 1

Use the Command Prompt instead of PowerShell.

  1. Switch your VSCode terminal to the Command Prompt enter image description here
  2. In the settings.json file, set the "python.condaPath" to your conda.exe. E.g.
"python.condaPath": "C:\\Users\\<user id>\\Anaconda3\\Scripts\\conda.exe"

Option 2

Set the PATH variable.

  1. Add the path to conda.exe to your PATH environment variable (per https://stackoverflow.com/a/66259191/11262633):
    "terminal.integrated.env.windows": {
            "PATH": "${env:PATH};C:\\Users\\<user id>\\Anaconda3\\Scripts"
    }
  1. Start a PowerShell terminal. You will get a message stating that Conda has not been initialized. Run the following command:
conda init

Note that as of the writing of this answer, conda init --help states that this command is experimental.

MicroSoft states that VSCode doesn't currently support automatically activating Conda environments using PowerShell. However, option 2 seems to work.

mherzog
  • 1,085
  • 1
  • 12
  • 24