Explain Codes LogoExplain Codes Logo

'conda' is not recognized as internal or external command

python
conda
environment-variables
anaconda
Anton ShumikhinbyAnton Shumikhin·Oct 29, 2024
TLDR

To quickly navigate the "Conda not recognized" error, add Conda to your PATH. Run these lines in your Command Prompt or Terminal:

Windows:

set PATH=%PATH%;C:\Anaconda3\Scripts;C:\Anaconda3

macOS/Linux:

export PATH="$HOME/anaconda3/bin:$PATH"

Replace C:\Anaconda3 or $HOME/anaconda3 with your actual Conda installation location. Apply these changes for the ongoing session or persistently add them to your system's environment variables for all future sessions.

Step-By-Step Resolution

Step 1: Check Conda installation

Confirm Anaconda or Miniconda is correctly installed by checking the directories in which they reside:

where python # For Sherlock Holmes using Windows where conda # Watson, give me the location!
which python # For macOS/Linux users playing hide-and-seek which conda # Have you seen my friend, Conda?

Step 2: Set environment variables manually

If you're on Windows, navigate through Advanced System Settings to get to Environment Variables. For Windows 10 users, performing this in administrator mode might be advantageous:

  • Hit Windows key + X and click System.
  • Hop into Advanced system settings.
  • In the System Properties window, journey to Environment Variables.
  • Under System Variables, hunt down Path and select Edit....
  • Click New and add the paths: C:\Anaconda3\Scripts and C:\Anaconda3.
  • Restart your Command Prompt to load the new environment variables.

On macOS/Linux, edit your shell's configuration file (like .bashrc or .bash_profile) and insert the export PATH command.

Step 3: Harness the power of the Anaconda Prompt

Use the Anaconda Prompt if available. This command-line tool comes with Anaconda:

🟢 Good to know: The Anaconda Prompt handles your path assignments like a backstage crew.

Step 4: Keep Anaconda current

Avoid issues by keeping your Anaconda up-to-date. How:

conda update conda conda update anaconda-navigator

Ask Conda to put on her newest dress!

Step 5: Inspect post-installation

After implementing the steps, restart your Command Prompt or Terminal and type:

conda --version

To list all conda-managed environments, use:

conda list

Facing persistent issues

Solution 1: Temporary PATH Override

When in dire need, the setx command is your Batman:

setx PATH "%PATH%;C:\Anaconda3\Scripts;C:\Anaconda3"

Note: Use judiciously, Batman only arrives for serious business. Your system's permanent environment variables are at stake.

Solution 2: Assist older operating systems

If you're a Windows 7 user, double-check the PATH updating approach as it's a little vintage.

Solution 3: Mind your permissions

Permission issues might block changes on Windows. To defeat this villain, always run Anaconda updates with administrator rights.

Solution 4: Preventing potential problems

Unless you're a custom-configuration enthusiast, keeping the default settings during the Anaconda installation can make your life easier. Stay conventional for a smooth ride.