Explain Codes LogoExplain Codes Logo

Conda command not found

python
conda-installation
environment-variable
bashrc
Nikita BarsukovbyNikita Barsukov·Feb 2, 2025
TLDR

Sometimes, software just refuses to cooperate. Conda is no exception. If you're here because of the Conda command not found issue, fear not. This problem requires a simple addition to your system's PATH environment variable.

On UNIX-based systems like macOS or Linux, you can fix this with the following command:

echo "export PATH=$HOME/miniconda3/bin:$PATH" >> ~/.bashrc && source ~/.bashrc

For Windows, you'll need to manually modify the Environment Variables. Append the path to your Conda installation (it's probably C:\Users\YourUser\miniconda3\Scripts) to the system's PATH variable. After that, conda --version in your terminal should give you your Conda version, meaning you're back in business!

Deep dive into troubleshooting

Verifying your installation

Before you go deep into troubleshooting, double-check whether Miniconda or Anaconda is properly installed. Look into the installation path; it might differ from $HOME/miniconda3. If you've just got it installed and the terminal was already open during installation, you might need to restart the terminal or even the whole system to ensure the changes get loaded.

For zsh users

For those on team zsh instead of bash, you'll need to update the .zshrc file instead:

echo "export PATH=$HOME/miniconda3/bin:$PATH" >> ~/.zshrc && source ~/.zshrc

Remember to replace $HOME/miniconda3 with your own installation path.

Going all out with Z shell

If you're using zsh and Conda seems to work fine with bash, execute conda init zsh to have Conda properly set up for it. If .bashrc and .bash_profile are doing the heavy lifting in your shell configuration, you might want to ensure they are sourced in .zshrc as well. You can test your setup by running conda --version.

Check environment variable syntax

Ensure your .zshrc or .bashrc changes are correct. A syntax error can stop the new PATH from being recognized. This will make it seem like you're shouting into the void (a situation we programmers are more familiar with than we'd like).

macOS Catalina and beyond

On macOS Catalina onward, the Z-shell is the default and you can't use the root directory as liberally. You might need a conda-prefix-replacement tool. Consult the Anaconda blog posts or GitHub discussions for help with these species.

When all else fails, reinstall

If nothing works, consider reinstalling Anaconda or Miniconda. This could resolve any underlying issue the software was having, probably due to that bug that's been dancing the cha-cha in your configurations.