Conda command not found

382,771

Solution 1

If you're using zsh and it has not been set up to read .bashrc, you need to add the Miniconda directory to the zsh shell PATH environment variable. Add this to your .zshrc:

export PATH="/home/username/miniconda/bin:$PATH"

Make sure to replace /home/username/miniconda with your actual path.

Save, exit the terminal and then reopen the terminal. conda command should work.

Solution 2

If you have the PATH in your .bashrc file and are still getting

conda: command not found

Your terminal might not be looking for the bash file. Type bash in the terminal to ensure you are in bash and then try: conda --version

Solution 3

Maybe you need to execute "source ~/.bashrc"

Solution 4

For those experiencing issues after upgrading to MacOS Catalina.

Short version:

# 1a) Use tool: conda-prefix-replacement - 
# Restores: Desktop -> Relocated Items -> Security -> anaconda3
curl -L https://repo.anaconda.com/pkgs/misc/cpr-exec/cpr-0.1.1-osx-64.exe -o cpr && chmod +x cpr
./cpr rehome ~/anaconda3
# or if fails
#./cpr rehome ~/anaconda3 --old-prefix /Anaconda3
source ~/anaconda3/bin/activate

# 1b) Alternatively - reintall anaconda - 
# brew cask install anaconda

# 2) conda init
conda init zsh
# or
# conda init    

Further reading - Anaconda blog post and Github discussion.

Solution 5

Sometimes, if you don't restart your terminal after you have installed anaconda also, it gives this error.

Close your terminal window and restart it.

It worked for me now!

Share:
382,771
olivrg
Author by

olivrg

Updated on January 25, 2022

Comments

  • olivrg
    olivrg over 2 years

    I've installed Miniconda and have added the environment variable export PATH="/home/username/miniconda3/bin:$PATH" to my .bashrc and .bash_profile but still can't run any conda commands in my terminal.

    Am I missing another step in my setup? I'm using zsh by the way.

  • dlmeetei
    dlmeetei over 8 years
    Instead of exiting and reopening, Using source ~/.zshrc will do
  • Thomas Ahle
    Thomas Ahle over 6 years
    I tried this, but I still get an error when trying to install stuff CondaIOError: Missing write permissions in: /anaconda
  • Johnny
    Johnny over 6 years
    It works! But the path has a slight difference. export PATH="/Users/victorzhang/anaconda2/bin:$PATH", the path beginning is /Users/, instead of /home/ still thank you @olivrg
  • patti_jane
    patti_jane over 4 years
    thanks for this! But what is the reason we have to type bash?
  • Kenan
    Kenan over 4 years
    im not 100% sure but I think it's to let your command prompt read the bashrc file
  • bpz
    bpz over 3 years
    For those who don't know: copy the command in the .zshrc file that will be located in your /User/<yourusername>/ directory.
  • Vyacheslav Tsivina
    Vyacheslav Tsivina over 3 years
    Yes, the start script for conda was added inside your .bashrc file during installation, so you need to start bash shell to start the conda
  • maria
    maria over 3 years
    My binary was in condabin at in /usr/local/anaconda3--it's 2021 and I'm on a Mac. I added condabin to the path in .zshrc at /User/<yourusername>/ and it worked.
  • Oha Noch
    Oha Noch about 3 years
    On ubuntu i needed to refer to home so i used: export PATH="~/anaconda3/bin":$PATH and it worked
  • Karan Sharma
    Karan Sharma almost 3 years
    Can you explain what does this command actually do? Thanks!
  • Vinay Verma
    Vinay Verma over 2 years
    nano ~/.bashrc - then in the end add export PATH="/home/username/miniconda3/bin:$PATH" Make check if its miniconda or miniconda3 source ~./.bashrc
  • frmbelz
    frmbelz over 2 years
    Also instead of close/open terminal, could source ~/.bashrc OR . ~/.barshrc if bash is a shell you are using (to see your shell echo $0)
  • frmbelz
    frmbelz over 2 years
    echo $0 to see what shell if it is .bashrc or .zshrc OR ls -ld ~/.* to see which one is already there.
  • Gulzar
    Gulzar about 2 years
    where is .zshrc? Is it a mac thing?
  • olivrg
    olivrg about 2 years
    .zshrc is the configuration file. You can open it with your text editor using this command: nano ~/.zshrc
  • Hugo M. Zuleta
    Hugo M. Zuleta almost 2 years
    @KaranSharma I believe it resets the environment variables for your profile. If you recently installed Anaconda, that file was edited by the installer with the new env variables, but have not been loaded for conda or other utilities. I might be wrong, I'm new to this whole thing.