How do you fix "'conda' is not recognized as an internal or external command" on Windows? | A1Lab@MZeeshanM to PythonEnglish • 3 days ago

How do you fix "'conda' is not recognized as an internal or external command" on Windows?

message-square
0

Initialize Conda for your Windows shell by launching Anaconda Prompt from the Start Menu and running conda init (e.g., conda init powershell or conda init cmd.exe), or add your Anaconda/Miniconda installation directories (...\anaconda3\Scripts and ...\anaconda3\condabin) to your Windows User Path environment variable—because the Windows installer leaves conda off the system PATH by default to prevent DLL conflicts with other Python installations.

Basic Example

# 1. Recommended: Open "Anaconda Prompt" (or "Anaconda PowerShell Prompt") from the Windows Start Menu,
#    then register `conda` with your regular Command Prompt and PowerShell shells:
conda init cmd.exe powershell

# 2. If PowerShell blocks the newly created profile script with an ExecutionPolicy error,
#    allow local signed/user scripts in standard PowerShell:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

# 3. Close and reopen your regular PowerShell or Command Prompt window, then verify:
conda --version
# Output: conda 24.x.x (or 25.x.x)
# Alternative (if you cannot find Anaconda Prompt): Invoke `conda.exe` directly by full path
# to run `conda init` from any standard PowerShell window:
& "$env:USERPROFILE\anaconda3\Scripts\conda.exe" init cmd.exe powershell
# (For Miniconda, replace `anaconda3` with `miniconda3`; for all-users installs, use `C:\ProgramData\anaconda3`.)

Key Details & Edge Cases

  • Why conda init is preferred over manually editing Windows PATH:
    • Simply adding anaconda3\Scripts to PATH makes conda --version work, but conda activate myenv will still fail with CommandNotFoundError: Your shell has not been properly configured to use 'conda activate' until conda init injects the shell hook function into PowerShell’s $PROFILE or Command Prompt’s AutoRun registry key.
  • Locating your Anaconda / Miniconda installation folder when conda is missing:
    • Check the three standard Windows installation paths in order:
      1. Per-user Anaconda: C:\Users\<YourUsername>\anaconda3\
      2. Per-user Miniconda / Miniforge: C:\Users\<YourUsername>\miniconda3\ or C:\Users\<YourUsername>\miniforge3\
      3. System-wide (All Users) install: C:\ProgramData\anaconda3\ or C:\ProgramData\miniconda3\
  • Manual PATH entries if third-party IDEs (VS Code, PyCharm, Git Bash) still cannot find conda:
    • Press Win + R, run sysdm.cpl $\rightarrow$ Advanced $\rightarrow$ Environment Variables… $\rightarrow$ edit User Path, and add these two folders (adjusting the root path to match your install):
      • C:\Users\<YourUsername>\anaconda3\condabin
      • C:\Users\<YourUsername>\anaconda3\Scripts
    • Adding condabin and Scripts exposes conda.bat / conda.exe without placing the root anaconda3\ Python interpreter ahead of other system tools.
  • Fixing conda in Git Bash on Windows (conda init bash):
    • conda init without arguments only configures cmd.exe (and powershell depending on version). To enable conda inside Git Bash (MINGW64), run conda init bash, then restart Git Bash so ~/.bash_profile sources conda.sh.
  • Restarting open terminals and IDEs is mandatory:
    • Already-open PowerShell, Command Prompt, and VS Code windows cache old environment variables and startup profiles in memory. Close all terminal tabs (or restart VS Code completely) after running conda init before testing conda --version.

Comparison of Fixes for 'conda' is not recognized on Windows

Method Enables conda --version? Enables conda activate <env>? Works in Standard PowerShell / CMD / VS Code? Best Used When
conda init cmd.exe powershell (via Anaconda Prompt or full path) (Recommended) Yes Yes (installs full shell activation hooks) Yes (after restarting terminal) Standard fix on Windows so both conda commands and conda activate work everywhere.
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser N/A (unblocks PowerShell $PROFILE) Yes (enables conda init hook in PowerShell) Yes (PowerShell) PowerShell throws running scripts is disabled on this system after running conda init.
Adding ...\condabin and ...\Scripts to User Path Yes No (requires conda init for activate) Yes External GUI apps or scripts looking up conda.exe / conda.bat via PATH without a shell profile.
Using Anaconda Prompt from Start Menu Yes Yes Only inside that dedicated prompt window Quick one-off work without modifying global shell profiles or PATH.