58

I installed the latest version of Anaconda. Now I want to install OpenCV within it. When I type:

conda install -c https://conda.binstar.org/anaconda opencv

I get this message error: "conda is not recognized as internal command ..." (sorry, I try to translate from French because my OS is in French)

The problem is that conda comes with Anaconda, so I wonder why lauching Anaconda and type the above command does not work ?

Gabriel
  • 40,504
  • 73
  • 230
  • 404
  • where are you running the command? – Padraic Cunningham Feb 19 '15 at 17:41
  • @PadraicCunningham I open the shell of Anaconda and run them inside. Is it the right way ? –  Feb 19 '15 at 17:48
  • This has happened to me twice now. If I forget to install opencv via Conda from Binstar using Sudo it results in a broken Anaconda distribution. Something happens in the step where Conda itself is upgrading/updating - in the end the Conda command is no longer recognized. If I check my /anaconda/bin/ folder, there is no command called conda I guess I need to start using virtual environments so I stop breaking things... – Maxwell Grady Sep 27 '15 at 20:42
  • In my case, reopening the shell works. – tyrantqiao Mar 29 '18 at 00:56
  • 1
    As google still finds this in the top list, in windows the correct solution is not any of the answers here but this one: https://stackoverflow.com/questions/44515769/conda-is-not-recognized-as-internal-or-external-command – anishtain4 Feb 20 '19 at 20:52

16 Answers16

68

For Windows

Go to Control Panel\System and Security\System\Advanced System Settings then look for Environment Variables.

Your user variables should contain Path=Path\to\Anaconda3\Scripts.

You need to figure where your Anaconda3 folder is (i.e. the path to this folder) . Mine was in C:\Users.

For Linux

You need to add conda to PATH. To do so, type:

export PATH=/path/to/anaconda3/bin:$PATH.

Same thing, you need to figure the path to anaconda3 folder (Usually, the path is stored in $HOME)

If you don't want to do this everytime you start a session, you can also add conda to PATH in your .bashrc file:

echo 'export PATH=/path/to/anaconda3/bin:$PATH' >> ~/.bashrc

LucasBoatwright
  • 1,456
  • 1
  • 16
  • 20
fabda01
  • 3,384
  • 2
  • 31
  • 37
  • 1
    Re: the Windows path, looks to me like if you installed for all users, your conda installation (Anaconda, Miniconda, whatever) is in `C:\ProgramData` – DHW Oct 26 '19 at 16:43
  • 2
    I have Windows, I think I added the path (even I tried in both user variables and system variables) and ran cmd and it didn't recognized conda. – YoussefDir Jul 23 '20 at 12:36
  • 1
    I then uninstalled Anaconda and installed it with the path added (not the recommended settings). There might have been a better way by simply changing the settings. Anyway... – YoussefDir Jul 23 '20 at 16:39
  • Note: If you want to use DataSpell or PyCharm to create a Conda environment, you should not add Conda to the Windows environment variable because both IDEs will automatically detect it. – Omid Ostovari Jun 30 '23 at 14:17
44

I had a similar problem. I searched conda.exe and I found it on Scripts folder. So, In Anaconda3 you need to add two variables to PATH. The first is Anaconda_folder_path and the second is Anaconda_folder_path\Scripts

Ali Ismayilov
  • 1,707
  • 3
  • 22
  • 37
7

When you install anaconda on windows now, it doesn't automatically add Python or Conda to your path so you have to add it yourself.

If you don’t know where your conda and/or python is, you type the following commands into your anaconda prompt

enter image description here

Next, you can add Python and Conda to your path by using the setx command in your command prompt. enter image description here

Next close that command prompt and open a new one. Congrats you can now use conda and python

Source: https://medium.com/@GalarnykMichael/install-python-on-windows-anaconda-c63c7c3d1444

5

I had a similar problem and I did something like the below mentioned steps with my Path environment variable to fix the problem

  1. Located where my Anaconda3 was installed. I run Windows 7. Mine is located at C:\ProgramData\Anaconda3.

  2. Open Control Panel - System - Advanced System Settings, under Advanced tab click on Environment Variables.

  3. Under System Variables, located "Path" add the following: C:\ProgramData\Anaconda3\Scripts;C:\ProgramData\Anaconda3\;

Save and open new terminal. type in "conda". It worked for me.

Hope these steps help

Chetan_Vasudevan
  • 2,414
  • 1
  • 13
  • 34
4

You probably need to update your PATH variable to include where you have installed Anaconda.

See https://github.com/ContinuumIO/anaconda-issues/issues/41 for a similar issue.

Chironian
  • 45
  • 3
3

I suspect you forget to export PATH, anaconda/bin must be added in your $PATH. (Linux, OSX common problem). On Windows make sure you run install and commands as administrator.

ares777
  • 3,590
  • 1
  • 22
  • 23
  • I am running Windows 7, I did not find bin folder for Anaconda. Is there an equivalent folder under Windows or is it the same ? –  Feb 19 '15 at 17:29
  • There are other users on my computer, but when I installed Anaconda, I am the only user allowed to use it, so I think I am its administrator –  Feb 19 '15 at 17:36
  • check the install path maybe is /Users... and not in default C:\anaconda. Also scripts must be added to path. – ares777 Feb 19 '15 at 17:40
  • Yes, you are right , installation path is `C:\users\myname\AppData\...` Must i uninstall it and reinstall it so that the path will be `C:\Anaconda ...` ? –  Feb 19 '15 at 17:47
  • no, just you add this path to your path environment, also scripts path (scripts is a folder inside anaconda root ). – ares777 Feb 19 '15 at 17:48
  • yes, i did that already. But after the comment under my question directly, I run the command on CMD not within Anaconda shell. It seems the right place to run it. Now I just get an other error saying it is not able to connect to ... (i think it is because of the firewall) –  Feb 19 '15 at 17:53
3

Same problem with Anaconda running on Ubuntu 15.10. I closed the terminal and opened a new window and it worked fine.

scdavis50
  • 111
  • 1
  • 5
3

Faced the same problem running on Windows 10 and using the Windows cmd.

Solved it by running the following command in the Anaconda Prompt which comes with Anaconda3 (as administrator):

conda install -c menpo opencv3=3.1.0

Command found on the official website: https://anaconda.org/menpo/opencv3

Eskapp
  • 3,419
  • 2
  • 22
  • 39
  • It's a shane anaconda.org doesn't mention the `Anaconda Prompt` program because searching for `conda` only turns up `.conda\` and `.condarc` - lost 90 minutes of my life because of this. – virtualxtc Aug 24 '18 at 03:33
3

Try setting the file path using (for anaconda3)...

export PATH=~/anaconda3/bin:$PATH

Then check whether it worked with...

conda --version

This worked for me when 'conda' was returning 'command not found'.

2

Try restarting the terminal, I had the same issue, worked after restarting the terminal.

Anubhav
  • 1,984
  • 22
  • 17
1

If this problem persists, you may want to check all path values in the PATH variable (under Control Panel\System and Security\System\Advanced System Settings). It might be that some other path is invalid or contains an illegal character.

Today, I had the same problem and found a double quote in a different path value in the PATH variable. All paths after that (including a fresly installed conda) were not usable. Removing the double quote solved the problem.

Johan
  • 406
  • 6
  • 20
1

In Windows 10, I went to the folder where Anaconda is stored. In my case it is in \Anaconda3 folder as a shortcut to open a command prompt window, called "Anaconda Prompt". Open that and execute the command there.

wrightwx
  • 11
  • 1
1

Got same issue and it turns out that besides setting PATH variable, I also should not close some cmd window poped up during installation. Re-installation would work

Joseph Liu
  • 21
  • 1
1

It's not recommended to add conda.exe path directly into the System Environment Variables at stated by anaconda installer :

enter image description here

For Windows Users, Open Conda Prompt Shortcut and change the Target into the Correct Address :

enter image description here

smbanaei
  • 1,123
  • 8
  • 14
0

As other users said, the best way for Windows users is to set the global environment variable.

I install the Miniconda3 for MXNet.

Before I do something, only Anaconda Prompt works for conda.

After setting the global environment variable, The CMD and Git Bash work. But in some IDEs like RStudio, the nested Git Bash doesn't work.

After restarting my computer, the Git Bash in the RStudio works for conda.

I hope these tests helps for you.

Jiaxiang
  • 865
  • 12
  • 23
0

On Windows 11 x64, default is

"C:\ProgramData\Anaconda3\Scripts\conda.exe"

CMD, run, systempropertiesadvanced , add to PATH variable.

enter image description here

enter image description here

Vy Do
  • 46,709
  • 59
  • 215
  • 313