'The term 'conda' is not recognized as the name of a cmdlet
I have installed Anaconda 2019.03 for Windows Installer in Windows 10.
When typing anything which starts with conda
on Powershell getting 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.
I have tried below solutions, which did not solved the problem:
'C:\Users\user-name\Anaconda3\Scripts\activate.bat' is not recognized as an internal or external command, operable program or batch file.
- Looked at above direction, there is not
activate.bat
file there. - Uninstall and install as shown on metod 2, also did not changed anything.
- Opened Anaconda Powershell Prompt in addition to 'conda' is not recognized also getting below error:
& : The term 'C:\Users\user-name\Anaconda3\shell\condabin\conda-hook.ps1' 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.
- Actually, Path
C:\Users\user-name\Anaconda3\shell
do not exists when I have looked.
Additional information listed:
- I have installed MySQL on my PC
C:\Users\user-name\Anaconda3\envs
is empty- Avira antivirus installed
- Python 3.7.3 installed before Anaconda
What should I do to solve this problem?
Solution 1:[1]
Found an awesome medium post that lais this out cleanly:
- Install latest Anaconda + PowerShell
- Open Anaconda prompt, and type "conda init powershell"
- Open PowerShell and it should work.
Basically creates a file at "%userprofile%\Documents\WindowsPowerShell\profile.ps1" that PowerShell will execute every time it initiates, connecting it to PowerShell.
Source: https://hackf5.medium.com/how-to-enable-anaconda-in-powershell-7-on-windows-394ba62c3f9c
Solution 2:[2]
If you use the default "old" PowerShell 5, check whether the profile.ps1
in C:\Users\USER\Documents\WindowsPowerShell
contains:
#region conda initialize
# !! Contents within this block are managed by 'conda init' !!
(& "C:\Users\USER\anaconda3\Scripts\conda.exe" "shell.powershell" "hook") | Out-String | Invoke-Expression
#endregion
If you have a message that the profile.ps1 cannot be executed, solve that problem with set-executionpolicy remotesigned
(but: insecure, thus, not recommended!), see:
Windows PowerShell
Copyright (C) Microsoft Corporation. Alle Rechte vorbehalten.
Installieren Sie die neueste PowerShell für neue Funktionen und Verbesserungen! https://aka.ms/PSWindows
. : Die Datei "C:\Users\USER\Documents\WindowsPowerShell\profile.ps1" kann nicht geladen werden, da die Ausführung
von Skripts auf diesem System deaktiviert ist. Weitere Informationen finden Sie unter "about_Execution_Policies"
(https:/go.microsoft.com/fwlink/?LinkID=135170).
In Zeile:1 Zeichen:3
+ . 'C:\Users\USER\Documents\WindowsPowerShell\profile.ps1'
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : Sicherheitsfehler: (:) [], PSSecurityException
+ FullyQualifiedErrorId : UnauthorizedAccess
PS C:\WINDOWS\system32> set-executionpolicy remotesigned
Ausführungsrichtlinie ändern
Die Ausführungsrichtlinie trägt zum Schutz vor nicht vertrauenswürdigen Skripts bei. Wenn Sie die Ausführungsrichtlinie
ändern, sind Sie möglicherweise den im Hilfethema "about_Execution_Policies" unter
"https:/go.microsoft.com/fwlink/?LinkID=135170" beschriebenen Sicherheitsrisiken ausgesetzt. Möchten Sie die
Ausführungsrichtlinie ändern?
[J] Ja [A] Ja, alle [N] Nein [K] Nein, keine [H] Anhalten [?] Hilfe (Standard ist "N"): j
After entering j
, restart PowerShell. You will see the profile.ps1
in action:
Windows PowerShell
Copyright (C) Microsoft Corporation. Alle Rechte vorbehalten.
Installieren Sie die neueste PowerShell für neue Funktionen und Verbesserungen! https://aka.ms/PSWindows
Das Laden von persönlichen und Systemprofilen dauerte 1400 ms.
(base) PS C:\Users\USER>
In short, try to make it possible that the "profile.ps1" gets loaded. In my case, I did not need this trick anymore since I installed PowerShell 7 which is allowed to load the profile.ps1
by default. You might also just open the old PowerShell 5 from Visual Studio Code instead and change the settings so that conda init
runs at the start, see How to add anaconda powershell to vscode?.
Its profile.ps1
had the same content, you find it in C:\Users\USER\Documents\PowerShell\profile.ps1
.
When I start PowerShell 7, conda init
runs automatically, no insecure tricks needed. Therefore, just install PowerShell 7 in parallel (do not remove the old PowerShell 5!) and use the new version instead.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Jbbae |
Solution 2 |