Conda: Command not found

Viewed 19033

I'm a 17-year-old, and I am new to programming. I installed anaconda and python on my laptop however every time that I run code in Sublime Text it gives this error before printing whatever I want it to print: /Users/eyan/.bash_profile: line 20: conda: command not found It's really annoying so is there a way to get rid of it.

2 Answers

The difference between bash and zshell are minimal. They are both a "shell" that run in the terminal. A shell is what allows you to run commands in the terminal. It has its own language called bash or alternatively shell scripting. If you have ever typed ls or cd in a terminal, you are using bash commands to move around or look at things in the terminal. (The terminal itself is just the little oftentimes black square you type into.) It doesn't really matter which one you pick at this point, but you should just go with one.

If you pick bash, the files that interact with it will be under your home directory, the error tells you exactly where. /Users/eyan/.bash_profile the .bash_profile sets some configurations for bash.

If you pick zshell, the files will instead of starting with '.bash_ they'll start with .zsh the most common one will be .zshrc and it will be in the same home directory. So /Users/eyan/.zshrc will be the config file for zshell.

Pick one and just stay with it for now.

In either case, you want to initialize conda.

In your terminal, if you type:

which conda

It should tell you where your conda is installed. If you get a bunch of nonsense running that, try which python. One of them should give you something like this output:

/Users/eyan/opt/anaconda3/bin/python

Change the python in that line to activate and add the command source to the front. So type:

source /Users/eyan/opt/anaconda3/bin/activate

Once you've done that type:

conda init

All of this is done in the terminal. And that should add a bunch of stuff to your shell profiles. (That's those files in your home directory like .bash and .zshrc.)

If you close and reopen your terminal or type EXEC $SHELL in the same terminal window, you should be able to use conda.

You can also see what was added to your bash (or zsh) profiles by typing:

cat /Users/eyan/.bash_profile

(Or if you've chosen zshell, run cat /Users/eyan/.zshrc)

You'll see that conda added quite a few lines to it. Don't worry about what those lines do for now, but you can see them there.

That means that your shell doesn't know where to find conda binary. In order for him to know where to look for it you should run:

/absolute/path/to/anaconda3/folder/bin/conda init
source ~/.bash_profile

usually the default path should be ~/anaconda3 and therefore you should be good with

~/anaconda3/bin/conda init
source ~/.bash_profile
Related