Conda command not found
Asked Answered
P

29

206

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 Z shell (executable zsh) by the way.

Powers answered 6/2, 2016 at 20:58 Comment(9)
Did you try with full path /home/username/miniconda3/bin/conda?Persaud
And your zsh is set up to read .bashrc (I doubt it, it's called ._bash_rc for a reason)? By default zsh reads .zprofile and .zshrc, instead (plus .zlogin for login shells).Cavan
I've tried the full path /home/username/miniconda3/bin/conda. Unfortunately, it didn't work.Powers
@Cavan It is set up to read .bashrc. I have no issue with RVMPowers
@Powers Nevermind then. Did the full path invocation return an error message?Cavan
It didn't return any errors.Powers
@Cavan you were right. I wasn't set up to read the .bashrc. It's working now after adding the environment variable to .zshrc as you suggested. Cheers mate!Powers
Does this answer your question? How to run Conda?Disrepair
why isn't this already in my path? Why do I need to manually add it? :/Bashuk
P
318

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.

Powers answered 6/2, 2016 at 21:39 Comment(11)
Instead of exiting and reopening, Using source ~/.zshrc will doVersus
I tried this, but I still get an error when trying to install stuff CondaIOError: Missing write permissions in: /anacondaClo
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 @PowersAdjectival
For those who don't know: copy the command in the .zshrc file that will be located in your /User/<yourusername>/ directory.Disesteem
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.Equiponderance
nano ~/.bashrc - then in the end add export PATH="/home/username/miniconda3/bin:$PATH" Make check if its miniconda or miniconda3 source ~./.bashrcCal
where is .zshrc? Is it a mac thing?Essayistic
.zshrc is the configuration file. You can open it with your text editor using this command: nano ~/.zshrcPowers
why isn't this already in my path? Why do I need to manually add it? :/Bashuk
After adding conda path to the $PATH inside .bashrc, and running source .bashrc; you may also need to run conda initHirza
It is enough to do conda init zsh to setup conda for Z shell.Gemina
L
99

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

Lucia answered 2/6, 2017 at 1:12 Comment(6)
thanks for this! But what is the reason we have to type bash?Sundowner
im not 100% sure but I think it's to let your command prompt read the bashrc fileLucia
Yes, the start script for conda was added inside your .bashrc file during installation, so you need to start bash shell to start the condaTotipalmate
why isn't this already in my path? Why do I need to manually add it? :/Bashuk
when you installed conda you might have select NO to add to path since it's the default.Lucia
conda install with homeberw in mac need this command to export path export PATH="/opt/homebrew/anaconda3/bin:$PATH"Trench
C
53

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

Crucifixion answered 3/6, 2017 at 8:38 Comment(3)
Can you explain what does this command actually do? Thanks!Munguia
@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.Ornery
@Karan Sharma: The mysterious "sourcing" explainedPutto
D
44

To initialize your shell, run the below code:

source ~/anaconda3/etc/profile.d/conda.sh
conda activate Your_env

It worked for me. I got the solution from the below link
https://www.codegrepper.com/code-[“CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'.][1]examples/shell/CommandNotFoundError%3A+Your+shell+has+not+been+properly+configured+to+use+%27conda+activate%27.+To+initialize+your+shell%2C+run

Dalliance answered 13/11, 2020 at 5:32 Comment(3)
Don't forget to replace anaconda3 with miniconda3 if you're using miniconda.Intuitive
This works only on current terminalHaystack
That is some completely messed up link! Can you fix it? (But *** *** *** *** *** *** *** without *** *** *** *** *** *** *** "Edit:", "Update:", or similar - the answer should appear as if it was written today)Putto
T
42

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

Close your terminal window and restart it.

It worked for me now!

Twannatwattle answered 21/10, 2017 at 18:41 Comment(1)
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)Hi
R
34

For those experiencing issues after upgrading to macOS v10.15 (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 - reinstall Anaconda -
# brew cask install anaconda

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

Further reading - Anaconda blog post and GitHub discussion.

Ripe answered 29/10, 2019 at 20:55 Comment(0)
S
22

conda: command not found

Try adding the below line to your .bashrc file:

export PATH=~/anaconda3/bin:$PATH

Then try:

conda --version

to see the version.

And then for it to take effect

conda init
Seminole answered 27/5, 2021 at 8:29 Comment(0)
P
18

Maybe you should type add this to your .bashrc or .zshrc

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

It worked for me.

Procrastinate answered 11/2, 2019 at 7:16 Comment(2)
On ubuntu i needed to refer to home so i used: export PATH="~/anaconda3/bin":$PATH and it workedLauds
echo $0 to see what shell if it is .bashrc or .zshrc OR ls -ld ~/.* to see which one is already there.Hi
T
10

If you are using Mac and have installed Conda with Homebrew then you need to run this command to export the path:

export PATH="$PATH:/opt/homebrew/anaconda3/bin"
Trench answered 16/11, 2022 at 12:27 Comment(0)
L
8

Execute the following command after installing and adding to the path

source ~/.bashrc

where source is a bash shell built-in command that executes the content of the file passed as argument, in the current shell.

It runs during boot up automatically.

Limestone answered 10/9, 2018 at 6:24 Comment(0)
T
6

I had the same issue. I just closed and reopened the terminal, and it worked. That was because I installed Anaconda with the terminal open.

Tinkling answered 15/8, 2018 at 17:1 Comment(0)
F
4

I faced this issue on my Mac after updating Conda. The solution was to run the Conda mini installer on top of the existing Conda setup.

curl https://repo.continuum.io/miniconda/Miniconda3-latest-MacOSX-x86_64.sh -o ~/miniconda3.sh
bash ~/miniconda3.sh -bfp ~/miniconda3

On Linux, you can use:

curl https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -o ~/miniconda3.sh
bash ~/miniconda3.sh -bfp ~/miniconda3

For other versions, you can go to https://repo.continuum.io/miniconda/

For details, check: Conda command not found after running conda update package #1364

Friesian answered 30/9, 2017 at 14:53 Comment(0)
M
3

I had to run the following command to activate the shell:

eval "$(/home/username/anaconda3/bin/conda shell.bash hook)"
Moshemoshell answered 21/5, 2021 at 17:53 Comment(0)
G
3

If you are using Linux:

After installing Anaconda from the .sh file (which you can download from https://www.spyder-ide.org/):

Step 1: Activate the environment in the terminal by entering the below command.

source ~/anaconda3/bin/activate

Step 2:

Type spyder in the terminal. You can get the Spyder IDE.

spyder
Gallman answered 10/1, 2023 at 5:28 Comment(0)
S
2

Make sure that you are installing the Anaconda binary that is compatible with your kernel.

I was in the same situation. It turned out I have an x64_86 CPU and was trying to install a 64-bit POWER8 installer. You can find out the same for your CPU by using the following command. It gives you a basic information about a computer's software and hardware.

uname -a

https://www.anaconda.com/download/#linux

The page in the link above displays two different types of 64-bit installers:

  • 64-bit (x86) installer and
  • 64-bit (POWER8) installer.
Scuttle answered 14/10, 2017 at 13:29 Comment(0)
E
2

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

Essam answered 18/2, 2021 at 6:4 Comment(1)
That is a bit terse. In what context? Where should it be applied?Putto
C
1

The brute-force way could be

if [ $? -eq 0 ]; then
    eval "$__conda_setup"
else
    if [ -f "/root/miniconda3/etc/profile.d/conda.sh" ]; then
        . "/root/miniconda3/etc/profile.d/conda.sh"
    else
        export PATH="/root/miniconda3/bin:$PATH"
    fi
fi

Then initialize and test Conda.

conda init
conda -V

Which is what Conda tries to do. Take a look at the end of ~/.bashrc with less ~/.bashrc or with cat ~/.bashrc

Chevet answered 12/5, 2021 at 2:4 Comment(0)
H
1

Do the same thing as the suggestion given by bash console, but pay attention that there are some errors in the suggestion (the file path format is incorrect). Paste these two commands in the Bash console for Windows:

echo ". C:/Users/mingm/Anaconda3/etc/profile.d/conda.sh" >> ~/.bashrc

and

echo "conda activate" >> ~/.bashrc

After having pasted these two commands, exit the Bash console, reload it and then activate the virtual environment by entering "conda activate your_env_name".

Hummock answered 29/5, 2021 at 10:5 Comment(0)
C
1

It can be a silly mistake. Make sure that you use anaconda3 instead of anaconda in the export path if you installed it so.

Chickenhearted answered 10/6, 2021 at 7:8 Comment(0)
A
1

By default, Anaconda and Miniconda will put necessary command alias to the .bashrc file file.

All you have to do is to reload added alias inside ~/.bashrc using this command:

source ~/.bashrc
Animalist answered 28/1, 2023 at 6:49 Comment(1)
This works. Alternatively, if you are using zsh, you need to source ~/.zshrcEnzymolysis
B
1

I am using a WSL system.

In my case, for the conda command to be added to the path, and persist, I had to do the following:

First:

vim ~/.bashrc

This will open the .bashrc file using Vim. You should go to the bottom of the file using the arrow keys, click i to toggle the insert mode and paste: export PATH="$PATH:/home/userName/miniconda3/bin".

After that, save and close Vim using :wq.

(if you are not comfortable using Vim, you can use the nano command instead)

nano ~/.bashrc

Second:

source ~/.bashrc

Third:

Close and open the terminal! This should work for everyone.

To test if it is working, try:

conda --version
Backhanded answered 14/4, 2023 at 13:20 Comment(0)
D
0

For Conda > 4.4 follow this:

echo ". /home/ubuntu/miniconda2/etc/profile.d/conda.sh" >> ~/.bashrc

Then you need to reload user bash, so you need to log out:

exit

And then log again.

Drome answered 8/6, 2020 at 6:35 Comment(1)
What do you mean by "reload user bash"? Reload the content of file .bashrc? Or something to do with file /usr/bash? Or something else?Putto
H
0

This worked for me on CentOS and miniconda3. Find out which shell you are using

echo $0

conda init bash (could be conda init zsh if you are using zsh, etc.) - this adds a path to ~/.bashrc

Reload command line

sourc ~/.bashrc OR . ~/.bashrc

Hi answered 7/12, 2021 at 21:21 Comment(0)
T
0

I have encountered this problem lately and I have found a solution that worked for me. It is possible that your current user might not have permissions to anaconda directory, so check if you can read/write there, and if not, then change the files owner by using chown.

Thetisa answered 24/1, 2022 at 14:31 Comment(0)
P
0

This worked on an M1 Mac:

To get the user name:

echo $USER

Then substitute my_username with the correct one.

source /Users/my_username/opt/anaconda3/bin/activate
Pyromania answered 25/10, 2022 at 8:38 Comment(0)
S
0

For me uninstalling and reinstalling miniconda did the trick. I did lose all my existing repos but at least the command works now.

Sapient answered 30/11, 2023 at 9:2 Comment(0)
C
-1

Mac OS X: cd /Users/USER_NAME/anaconda3/bin && ./activate

Cleisthenes answered 28/11, 2020 at 15:15 Comment(0)
G
-1

on conda prompt try

conda init powershell
Geriatrics answered 14/2, 2023 at 14:11 Comment(1)
If conda isn't already in the path, how can they run that?Cycle
T
-1

To add Anaconda to your system's PATH as well as User PATH on Windows, you can follow these steps:

  1. Find Anaconda Installation Directory: The Anaconda installation directory will typically be something like C:\Users\<YourUsername>\Anaconda3 or C:\ProgramData\Anaconda3, depending on whether it's installed for a specific user or for all users.

  2. Open System Properties:

    • Right-click on the Start button and select System.
    • Click on Advanced system settings on the left-hand side.
  3. Environment Variables:

    • In the System Properties window, click the Environment Variables button at the bottom.
  4. Edit System Variables:

    • Under the "System Variables" section, find the Path variable and select it.
    • Click the Edit button.
  5. Add Anaconda Path:

    • Click the New button and add the path to the Anaconda installation directory. For example: C:\Users\<YourUsername>\Anaconda3 or C:\ProgramData\Anaconda3.
  6. Save and Apply Changes:

    • After adding the Anaconda path, click OK to close each of the open windows.

    • Repeat step 4,5 and 6 for adding the path to User PATH as well

  7. Restart Command Prompt:

    • If you have a Command Prompt or PowerShell open, close and reopen it for the changes to take effect.
  8. Verify Installation:

    • Open a new Command Prompt or PowerShell window.
    • Type conda --version and press Enter. This should display the version of Conda if the PATH configuration was successful.

Remember to replace <YourUsername> with your actual Windows username and adjust the installation path if you installed Anaconda in a different location.

Truckload answered 27/8, 2023 at 6:6 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.