262

I installed Anaconda and can run Python, so I assume that I installed it correctly. Following this introductory documentation, I am trying to install Python v3.3, so I am copying and pasting the following line into my console:

conda create -n py33 python=3.3 anaconda

However, that gives me an error:

-bash: conda: command not found

What do I need to do to run Conda?

I am working on a Linux system.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Ginger
  • 8,320
  • 12
  • 56
  • 99
  • 23
    After the Anaconda and Miniconda installs, there should have been a message like, "For this change to become active, you have to open a new terminal.". Close the terminal and reconnect, and your command should work. – JustBeingHelpful Oct 18 '16 at 06:18
  • 2
    I had similar issue and @MacGyver advice has helped, but I just did it with 'source .bash_profile' from home directory. – Yauhen May 20 '18 at 08:58
  • @MacGyver You are so damn right! – Code42 Jun 02 '19 at 14:49

33 Answers33

431

You might want to try this:

For Anaconda 2:

export PATH=~/anaconda2/bin:$PATH

For Anaconda 3:

export PATH=~/anaconda3/bin:$PATH

For Anaconda 4:

Use the Anaconda Prompt.

And then

conda --version

to confirm that it worked.

The export PATH=~/anaconda3/bin:$PATH works, but it stops when you exit the terminal in order change that you have to run sudo nano ~/.bashrc and then copy the path into the file and save it after that you activate the changes using source .bashrc.

Check with conda install anaconda-navigator. If not installed, follow the Anaconda install instructions again

Follow along with the video https://youtu.be/Pr25JlaXhpc.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
madcurie
  • 4,343
  • 2
  • 9
  • 4
  • 8
    or `export PATH=~/anaconda/bin:$PATH` where appropriate – Little Bobby Tables Jul 18 '16 at 21:23
  • 3
    When I type `export PATH=~/anaconda3/bin:$PATH` into the terminal and then run `conda --version` it works fine. When I copy it into my .bashrc file, open terminal, and run `conda --version` it doesn't work. Any ideas why? – NewNameStat May 09 '17 at 16:37
  • @NewNameStat: See this thread https://stackoverflow.com/questions/9127405/path-not-being-saved-after-i-leave-terminal – petezurich Aug 22 '17 at 19:56
  • 3
    if I open a terminal and apply these changes, it works but if I close the terminal and reopen it, it again shows me the old python path not condo. I tired it by removing all old path and still the same behavior.!! – Reihan_amn May 09 '18 at 00:23
  • I'm on elementaryOS (derived from Ubuntu 16.04). To update the PATH each time I login, I add PATH="$HOME/anaconda3/bin:$PATH" to ~/.profile – RTbecard Oct 28 '18 at 14:01
  • @Reihan_amnI have this problem too! Does anybody have some solution? – Mohammad Javad Dec 10 '19 at 01:48
  • I have done the same thing. But it didn't work until I did "conda --version". Everything is working fine now – Nafi Shahriyar Dec 23 '19 at 05:49
  • I've done the previous, and as I change the conda env, it (conda command) doesn't work, any idea? – Mike Mar 16 '20 at 15:46
  • 4
    **Note:** Doing this "manually" is discouraged. [This answer](https://stackoverflow.com/a/55526573/11301900) shows the right solution. – AMC Jun 11 '20 at 00:12
  • @madcurie, may I know where can I find the video because the link is not working https://youtu.be/Pr25JlaXhpc? – Susan Aug 08 '22 at 04:45
  • The link is (effectively) broken: *"Video unavailable. This video is no longer available because the YouTube account associated with this video has been terminated."* – Peter Mortensen Apr 20 '23 at 14:39
81

It turns out that I had not set the path.

To do so, I first had to edit .bash_profile (I downloaded it to my local desktop to do that; I do not know how to text edit a file from Linux)

Then add this to .bash_profile:

PATH=$PATH:$HOME/anaconda/bin
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Ginger
  • 8,320
  • 12
  • 56
  • 99
  • 2
    The anaconda installer usually does this for you, unless you explicitly tell it not to. – asmeurer Sep 08 '13 at 02:51
  • 14
    You may want to add `$HOME/anaconda/bin` to the front of your PATH, so that the Anaconda Python becomes your default Python. – asmeurer Sep 08 '13 at 02:51
  • 5
    @asmeurer The Anaconda installer does *not* do this for you, unless you explicitly tell it to. The default is "no". – endolith Nov 04 '15 at 00:17
  • 8
    The default is no on Linux. It's yes on Windows and OS X. – asmeurer Nov 04 '15 at 00:35
  • 5
    Make sure to close and reopen your terminal after you modify your .bash_profile. I couldn't figure out why this wasn't working until I did so. – Horatio Jan 02 '16 at 05:24
  • 1
    The comment of @Horatio nailed it! You Do have to close the terminal. – Eduardo Barbaro Jul 25 '16 at 13:08
  • @asmeurer That's what I did with my Miniconda installation, but is it a good enough practice? – art-solopov Nov 25 '16 at 14:45
  • 1
    `Do you wish the installer to prepend the Anaconda2 install location to PATH in your /home/hadoop/.bashrc ? [yes|no] [no] >>>` @asmeurer – d8aninja Oct 03 '17 at 23:04
58

Use conda init

As pointed out in a different answer, manually adding Conda on $PATH is no longer recommended as of v4.4.0 (see Release Notes). Furthermore, since Conda v4.6 new functionality to manage shell initialization via the conda init command was introduced. Hence, the updated recommendation is to run

Linux/UNIX and OS X before macOS v10.15 (Catalina)

./anaconda3/bin/conda init

Mac OS X v10.15 (Catalina) and later

./anaconda3/bin/conda init zsh

Windows

./anaconda3/Scripts/conda.exe init

You must launch a new shell or source your init file (e.g., source .bashrc) for the changes to take effect.

Details. For an in-depth look at exactly what conda init does see this answer.


Alternative shells

You may need to explicitly identify your shell to Conda. For example, if you run zsh (Mac OS X 10.15+ default) instead of bash then you would run

./anaconda3/bin/conda init zsh

Please see ./anaconda3/bin/conda init --help for a comprehensive list of supported shells.


Word of Caution

I'd recommend running the above command with a --dry-run|-d flag and a verbosity (-v) flag, in order to see exactly what it would do. If you don't already have a Conda-managed section in your shell run commands file (e.g., .bashrc), then this should appear like a straight-forward insertion of some new lines. If it isn't such a straightforward insertion, I'd recommend clearing any previous Conda sections from $PATH and the relevant shell initialization files (e.g., bashrc) first.

Again, for those interested, there is an in-depth look at how it works, in this answer.


Potential Automated Cleanup

Conda v4.6.9 introduced a --reverse flag that automates removing the changes that are inserted by conda init.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
merv
  • 67,214
  • 13
  • 180
  • 245
  • is there a .bashrc on windows 10? – john k Aug 22 '19 at 15:54
  • @johnktejik it all depends on the shell you're running. When you run `conda init` with the verbose flag `-vv` it will tell you exactly what it's going to edit. – merv Aug 22 '19 at 15:59
  • 1
    `conda init` overwrites both your `C:\Users\\Documents\WindowsPowerShell\profile.ps1` and `C:\Users\\Documents\PowerShell\profile.ps1`. – not2qubit Mar 27 '20 at 04:30
  • @not2qubit have you reported that on GitHub Issues? That doesn't seem like something they would be doing intentionally. – merv Jun 17 '20 at 02:40
  • 1
    It's been [repeatedly](https://github.com/conda/conda/issues?q=is%3Aissue+profile.ps1) reported, opened and closed. – not2qubit Sep 19 '20 at 08:24
  • @not2qubit thanks for pointing that out. Do you think we should add a warning directly in the answer? Also, does running with `--dry-run` correctly show what it would change? – merv Oct 02 '20 at 03:23
27

If you have installed Anaconda, but you are not able to load the correct versions of Python and IPython, or if you see "conda: command not found" when trying to use Conda, this may be an issue with your PATH environment variable. At the prompt, type:

export PATH=~/anaconda/bin:$PATH

For this example, it is assumed that Anaconda is installed in the default ~/anaconda location.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
yonglin
  • 416
  • 1
  • 5
  • 8
  • 1
    This simply recapitulates earlier answers (e.g., https://stackoverflow.com/a/18675970/570918). – merv Mar 22 '19 at 17:25
27

This information is current as of 2016-08-10. Here are the exact steps I took to fix this using methods posted above. I did not see anyone post: export PATH=$PATH:$HOME/anaconda/bin (you need to add export to the beginning of the line).

Here it is, step-by-step:

For anyone running into the same problem while using Oh My Zsh, you need to do the following:

  • Open your .zshrc in your terminal. I am using iTerm 2 and have Sublime Text 3 as my default text editor:

    subl ~/.zshrc

  • Once the file opens in your text editor, scroll to the very bottom and add:

    export PATH=$PATH:$HOME/anaconda/bin

  • Save the file, then close it.

  • Close your terminal, then relaunch it.

  • Once back in your terminal, type:

    conda --v

    You should then see the version of conda installed printed on your screen.


If you're using Z shell (executable zsh), then after doing that, your terminal may show you zsh: command not found: rvm-prompt.

The solution is:

  1. add alias rvm-prompt=$HOME/.rvm/bin/rvm-prompt within .zshrc file.
  2. type source .zshrc.

Then the zsh: command not found: rvm-prompt will disappear.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Eboi316
  • 287
  • 3
  • 4
26

My environment: macOS and Anaconda 3

This works for me:

nano ~/.bash_profile

Add this:

export PATH=~/anaconda3/bin:$PATH

The export path must match with the actual path of executable anaconda3 in the system.

Exit out and run:

source ~/.bash_profile

Then try:

jupyter notebook
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Zoe L
  • 1,150
  • 14
  • 22
23

Edit ~/.bash_profile, and add this to it.

PATH=$PATH:$HOME/anaconda/bin

Then run

source ~/.bash_profile
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Germey
  • 640
  • 6
  • 12
  • Thanks for this, this line also works for an oh-my-zsh profile where some of the other lines do not. – JimmyM Sep 03 '18 at 16:01
  • 2
    This merely recapitulates earlier answers (e.g., https://stackoverflow.com/a/18675970/570918) – merv Mar 22 '19 at 17:29
  • in my ~/.bash_profile there were already lines on anaconda2 and anaconda3 (probably result of the installation). I just had to run the second part of the answer `source ~/.bashprofile` (also for my macOSX Catelina zsh terminal) – Richard Nov 23 '19 at 22:09
16

I'm on macOS v10.13 (High Sierra) and just installed Anaconda 3 via a Homebrew command. I had an issue with running:

conda

It'd also give me:

-bash: conda: command not found

I tried running:

export PATH=~/anaconda3/bin:$PATH

But it needs entire path. So here are the correct steps:

nano ~/.bash_profile

Now export the entire path. In my case it was:

export PATH=/usr/local/anaconda3/bin:$PATH

Exit out and run:

source ~/.bash_profile

Then try:

conda

For example,

conda --version

Output:

conda 4.4.10
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Galapagos
  • 669
  • 6
  • 13
11

If you have just installed Anaconda and got this error, then I think you forgot to run this command:

  • source ~/.bashrc

This will enable you to make use of Anaconda in terminal.

This may seems simple, but many (including me) do this mistake.

If the error is still persisting, you have to verify if anaconda location is added to PATH in your system.

Once you add it, you'll be fine.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
smerllo
  • 3,117
  • 1
  • 22
  • 37
8

If you have installed Anaconda and have definitely said yes to the:

Do you wish the installer to prepend the Anaconda install location to PATH in your /home/name/.bashrc ? [yes¦no]

question then you maybe just need to restart your terminal window. The change won't take effect until you either (1) close and reopen the current window or (2) just open and start working in a new window

Basically, open a new console window and see if it works now.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
mjp
  • 1,618
  • 2
  • 22
  • 37
  • 2
    For me, all I had to do was restart the terminal and the conda command started working. ^^Underrated answer. – ian-campbell Apr 08 '17 at 19:04
  • I think this "answer" would be more appropriate as a comment. The question and answers here have to do with Anaconda installation, not terminal basics. Restarting the terminal is a good reminder, but it's not an answer to this question. – geneorama Jan 02 '19 at 16:09
  • Who cares? They had a problem which they were trying to solve and for some people (me included) this fixed the problem. Thus it is an "answer". – mjp Nov 11 '19 at 21:01
8

For Windows:

A recent Anaconda (version 4.4.0) changed some directories. You can find "conda" in Anaconda3/Scripts, instead of Anaconda3/bin.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
sehyun
  • 81
  • 1
  • 1
6

Mostly, it is because when we install Anaconda in the end, it adds the Anaconda path to PATH variable in the .bashrc file.

So we just need to restart the terminal or just do:

source ~/.bashrc

If still it doesn't work, then follow these commands:

cat >> ~/.bashrc

Paste the below command for Anaconda 3:

export PATH=~/anaconda3/bin:$PATH

Hit Enter and then Ctrl + D.

source ~/.bashrc
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Devendra Bhat
  • 1,149
  • 2
  • 14
  • 19
4

Using the export PATH= strategy with conda activate will result into a warning message for Conda 4.4 or later.

The recommended way (see this release note, and this post) to do it is to remove the export PATH=... line and instead add the following line in your .bashrc (or .bash_profile) file:

. ~/anaconda2/etc/profile.d/conda.sh

Furthermore, if you want Conda to be activated by default, add:

conda activate
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Matifou
  • 7,968
  • 3
  • 47
  • 52
3

If you have installed Anaconda, but if you are not able to execute a Conda command from the terminal, it means the path is probably not set, try:

export PATH=~/anaconda/bin:$PATH

See this link.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
user3651854
  • 124
  • 1
  • 8
3

I also was facing the same issue. This might be the simplest possible solution:

source anaconda/bin/activate

For Anaconda 2, use

source anaconda2/bin/activate

Depending on the name of the directory, then execute your command, i.e., conda --create.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
yunus
  • 2,445
  • 1
  • 14
  • 12
  • 1
    if that didnt help , try restarting , after that try " source ~/.bashrc", then try ur command. hope that helps. – yunus Aug 31 '18 at 13:48
2

Run

cat ~/.bash_profile

to check if Anaconda is there. If not, you should add its path there. If Conda is there, copy the entire row that you see the Anaconda there from "export" to the end of line.

Like this:

export PATH=~/anaconda3/bin:$PATH

Run this in your terminal.

Then run

conda --version

to see if it is exported and running!

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Reihan_amn
  • 2,645
  • 2
  • 21
  • 21
2

System: macOS

I installed Anaconda first, and everything worked well. Then I installed iTerm2 and when I typed Python, iTerm2 gave me the default Python. Here is how to find your Anaconda Python back:

  1. Open your .zshrc file. For example, vim ~/.zshrc

  2. Then add export PATH="/Users/yourusername/anaconda2/bin:$PATH" to the last line of the file. Note that you need to replace the yourusername to your user name and make sure you have anaconda2. An easy way is to copy this line from ~/.bash_profile.

  3. Save the file, close it, relaunch the terminal and now Anaconda Python should be back.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
2

Answer for


  1. Unfortunately, the installer puts the PATH definition only into .bash_profile, but not the .zshrc configuration.
  2. Contrary to the given answers, it doesn't (necessarily) install in ~/anaconda3/, but instead in /anaconda3/.

The PATH defintion in file .zshrc must therefore be this:

...
# Anaconda3
export PATH="/anaconda3/bin:$PATH"
...
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
think
  • 313
  • 1
  • 4
  • 14
  • The right way of doing this is to first run `source /bin/activate`, then `conda init zsh`. – AMC Jun 11 '20 at 00:18
1

Temporary solution:

$anaconda/bin/conda create -n py33 python=3.3 anaconda
Praneeth
  • 902
  • 2
  • 11
  • 25
1

If you have just installed Miniconda or Anaconda make sure you rerun your terminal.

From this, I mean close and open your terminal and then try conda list to verify your installation.

For me, this worked!!

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Mr. Suryaa Jha
  • 1,516
  • 16
  • 10
  • 1
    This essentially recapitulates an earlier answer: https://stackoverflow.com/a/39378909/570918 – merv Jul 08 '21 at 20:22
1

To edit .bashrc in Ubuntu:

/usr/bin/vim ~/.bashrc

Type PATH=$PATH:$HOME/anaconda3/bin.

Press Esc and :wq to save the .bashrc file and exit Vim.

Enter image description here

Then

export PATH=~/anaconda3/bin:$PATH

And type source ~/.bashrc.

Now to confirm the installation of Conda, type

conda --version
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Dr Jacob D
  • 25
  • 2
  • Please review *[Why not upload images of code/errors when asking a question?](https://meta.stackoverflow.com/questions/285551/)* (e.g., *"Images should only be used to illustrate problems that* ***can't be made clear in any other way,*** *such as to provide screenshots of a user interface."*) and [do the right thing](https://stackoverflow.com/posts/51619519/edit) (it covers answers as well). Thanks in advance. – Peter Mortensen Apr 20 '23 at 16:21
1

Open your terminal and type the following command to add Anaconda to environment path.

For Anaconda 2:

export PATH=~/anaconda2/bin:$PATH

For Anaconda 3:

export PATH=~/anaconda3/bin:$PATH

Then, to check the Conda version, just type,

conda --version

Create an environment using the following command,

conda create --name myenv

Activate the source using,

source activate myenv

Then your Anaconda IDE is ready!

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Codemaker2015
  • 12,190
  • 6
  • 97
  • 81
1

If you installed Anaconda with Visual Studio 2017 for Windows, conda executable is in this path or similar.

In my case path is this: C:\Program Files (x86)\Microsoft Visual Studio\Shared\Anaconda3_64\Scripts

Steps to add it to your PATH:

  • On the Windows desktop, right-click My Computer.
  • In the pop-up menu, click Properties.
  • In the System Properties window, click the Advanced tab, and then click Environment Variables.
  • In the System Variables window, highlight Path, and click Edit.
  • Add your path and restart your cmd.

You will be able to execute conda

Happy coding!

Lexsoul
  • 155
  • 2
  • 8
0

In my case, the Conda path was properly set (in .bashrc) by the Conda installation Bash script. But to make it works I had to give executable file permissions to files in bin sub folder with chmod +x *.

My system information:

  • Conda 4.2.9

  • Operating System: Debian 8 GNU/Linux 8 (Jessie)

  • Kernel: Linux 3.16.0-4-amd64

  • Architecture: x86-64

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
user278049
  • 113
  • 1
  • 4
0

I am setting up a virtual machine running Ubuntu. I have Anaconda 3 installed in the "Home" folder. When I typed "conda" into the terminal I was getting the error "conda: command not found" too.

Typing the code below into the terminal worked for me...

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

to check it worked I typed:

conda --version

which responded with the version number.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Mel
  • 6,214
  • 10
  • 54
  • 71
0

You need to put Anaconda.sh to your /home/<your_name_file>, and then run it to install. After that, you can runexport PATH=~/anaconda3/bin:$PATH. Remark: do not run Anaconda.sh in download/ directly!

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
erick lv
  • 9
  • 1
0

I had the same issue. I removed the Anaconda directory from the install location and reinstalled. After that, it worked as I anticipated.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Piusha
  • 594
  • 5
  • 11
0

First, check the location of Anaconda. For me, I installed Anaconda 3 at the / directory which I access with /anaconda3.

Then in your terminal, input export PATH="<base location>/anaconda3/bin:$PATH". For me, it's export PATH="/anaconda3/bin:$PATH".

Finally, input source $/anaconda3/bin/activate. For you, just change to your location.

Now, you could try conda list to test.

Also, visit the installation guide.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Zero
  • 1,142
  • 13
  • 10
0
  1. Check where you have installed Anaconda. In my case it looks like /home/nour/anaconda3/bin

  2. Open your .bashrc file. For example, gedit .bashrc

  3. Add this export PATH = /home/nour/anaconda3/bin:$PATH line at the end of the file and save.

  4. Reopen the terminal. Type conda --version

Note: Make sure the path in 1. and 3. are the same. In my case, /home/nour/anaconda3/bin.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Nour Noby
  • 97
  • 1
  • 3
0

The main point is that, as of December 2018, it's Scripts, not bin.


Updating $PATH in Git Bash for Windows

Use one of these: export PATH=$USERPROFILE/AppData/Local/Continuum/anaconda2/Scripts/:$PATH export PATH=$USERPROFILE/AppData/Local/Continuum/anaconda3/Scripts/:$PATH


Updating $PATH in the Windows default command line

Use one of these: SET PATH=%USERPROFILE%\AppData\Local\Continuum\anaconda2\Scripts\;%PATH% SET PATH=%USERPROFILE%\AppData\Local\Continuum\anaconda3\Scripts\;%PATH%


Updating $PATH in Linux

Change /app to your installation location. If you installed Anaconda change Miniconda to Anaconda. Also, check for Script vs. bin,

export PATH="/app/Miniconda/bin:$PATH"

You may need to run set -a before setting the path, I think this is important if you're setting the path in a script. For example if you have your export command in a file called set_my_path.sh, I think you'd need to do set -a; source("set_my_path.sh").

The set -a will make your changes to the path persist for your session, but they are still not permanent.

For a more permanent solution add the command to ~/.bashrc. The installers may offer to add something like this to your ~/.bashrc file, but you can do it too (or comment it out to undo it).


General Observations:

Background: I installed the 64-bit versions of Anaconda 2 and 3 recently on my Windows 10 machine following the recommended installation steps in December of 2018.

  • Adding Conda also enables IPython, which works much better in the native Windows command line
  • Following the strongly recommended installation does not add Conda or IPython to the path
  • Anaconda 3 doesn't seem to install a command prompt application, but Anaconda 2 did have a command prompt application
  • The /bin folder seems to have been replaced with Scripts
  • Poking around in the Scripts folder is interesting, maybe the Anaconda command prompt application is in there somewhere.
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
geneorama
  • 3,620
  • 4
  • 30
  • 41
-1

For Windows:

PATH=%USERPROFILE%\Continuum\Anaconda4.4.0\Library\bin;%PATH%
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
tisaconundrum
  • 2,156
  • 2
  • 22
  • 37
-1

Type anaconda-navigator in the terminal.

Then the Anaconda application will be start.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Mohammad Heydari
  • 3,933
  • 2
  • 26
  • 33
-1

Similar to the above, remember that you could have Miniconda instead of Conda, so you might want to add

export PATH=${PATH}:/Users/davidfortini/miniconda3/bin to .zshrc or .bash_profile and then reboot the terminal.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
DaveR
  • 1,696
  • 18
  • 24