conda not recognized as an internal or external command - cmd

I've installed Anaconda and now I want to create a conda environment,
C:> conda create -n tensorflow pip python=3.5
but then I get the error that "conda" is not recognized as an internal or external command.
How can I fix this?

As Windows user you have to start a Anaconda Prompt from the start menu. Look in your start menu for anaconda3-64bit -> anaconda prompt.
Now the conda command should be found in this shell.
Otherwise add the Anaconda Binaries folder to your environment path.

Related

Conda is not recognized as an internal or external command

Command line screen capture
I have successfully installed Anaconda on my drive D and added it to my path so that I am able to access it from cmd without using the Anaconda prompt.
However, after running where conda on the Anaconda prompt, I got the 3 different locations
- D:\Anaconda\Library\bin\conda.bat
- D:\Anaconda\Scripts\conda.exe
- D:\Anaconda\condabin\conda.bat
to set as paths but after doing that, the conda command on my command line still does not work.
From the error image and description of the issue, I can see that you have installed the anaconda in the D:\ drive and tried to access it through the C:\ drive.
To access the conda in command prompt, you need to run the below commands :
C:\Users\Loni Tande>cd D:\Anaconda\Scripts
D:\Anaconda\Scripts>conda
D:\Anaconda\Scripts>conda --version
Please make sure you have the latest Anaconda version installed in your system to access all its functionalities.

I got error Internal or external command error by command prompt only, but it is fine in anaconda prompt. Why?

If I want to open a jupyter notebook by command prompt I got below error:
'jupyter' is not recognized as an internal or external command,
operable program or batch file.
And also, I want to use pip commands, I got the same error:
'pip' is not recognized as an internal or external command,
operable program or batch file.
But in anaconda prompt I did not get any error it is run finely. I can open jupyter notebook without any error and also I can run pip without any error to install packages.
What can I do for command prompt to overcome this error?
Anaconda Prompt adds the path to the Anaconda binaries (jupiter, pip, etc.) to the PATH environment variable, so you can run them as commands from the prompt.
To be able to run the commands from the "normal" prompt you can manually add the path to the corresponding binaries to the PATH environment variable. Or choose the corresponding option while installing Anaconda (see Step 8 in the installation instructions).
Note the recommendation in the docs:
We do not recommend adding Anaconda to to the PATH environment variable, since this can interfere with other software. Instead, use Anaconda software by opening Anaconda Navigator or the Anaconda Prompt from the Start Menu.

I have added conda and python path to the environment variable, but jupyter notebook is still not getting opened from cmd

I was trying to add conda and python to the environment variable using SETX Command from CMD but it was failing. I tried setting it using PowerShell and it worked. The path was added successfully but I still can't open Jupyter Notebook from my cmd.
Adding Python to the environment path is bad practice, see Anaconda FAQ. If you haven't installed Anaconda with it's default settings, you first need to:
Initialize your shells
conda init --all
After this you should have ../Anaconda3/condabin only in your path (more information via conda init --help).
But before you can run Jupyter, you also need to activate Anaconda:
C:\> conda activate
(base) C:\> jupyter notebook
The activation will add the following folders of the conda base environment to your PATH:
\Anaconda3;
\Anaconda3\Library\mingw-w64\bin;
\Anaconda3\Library\usr\bin;
\Anaconda3\Library\bin;
\Anaconda3\Scripts;
\Anaconda3\bin;
The python.exe resides in Anaconda3, jupyter.exe in Anaconda3\Scripts, so it's not enough to just add the first folder to your Path. And it's especially important to have the libraries on your Path when you want to run C-based packages like numpy.
But the very point behind the conda activate mechanism is that it allows you to configure and run different environments with different versions of python and 3rd party packages that would otherwise conflict, see Managing environmnts.
On top of that you can even install Python from python.org next to your Anaconda distribution, since conda will make sure that they won't interfere.

running source activate <env> in Anacaonda Promt fails

There are already many posts describing how to solve 'source' is not recognized as an internal or external command," by adding anaconda to path.
Following the recommended approach is to not check the box to add Anaconda to your path.
How can i start my env from the Anaconda Promt?
conda 4.6.11
conda env list show my env's
conda activate environmentNameHere in the Anaconda terminal will do it. If you want to deactivate an environment you just type conda deactivate

Error activating Conda environment in Windows

I was attempting to use anaconda to download tensorflow. I followed the guide character by character. Anaconda downloaded and installed. I used the command:
c:>conda create -n tensorflow python=3.5
which worked, then I used:
c:> activate tensorflow
Which failed to change to a # prompt. So I tried using pip install and got an error message:
'pip' is not recognized as an internal or external command, operable
program or batch file.
Does anyone have any suggestions on how to correct this?
Did you mean to use:
conda create -n tensorflow tensorflow python=3.5
the conda command:
conda install -n <env_name> <package>
translates your code
conda install -n tensorflow pythong-3.5
tells conda to:
- create a new environment,
- that you want your new environment to be named tensorflow, and to
- install python version 3.5 in the environment you just created.
You did not actually tell conda to install TensorFlow.
Personally, I prefer to name my environment, then change into it to install packages:
conda create -n new_env_name python=3.5
source activate new_env_name
conda install tensorflow numpy pandas matplotlib
* Note: if you are on Windows, you may need to use activate my_env_name instead of source activate my_env_name to start your environment.
Which command to use is dependent on what terminal window you are using:
- Powershell requires activate my_env_name,
- Git Bash requires source activate my_env_name.
Often instructions naively state the the former is always used when on a Windows system.
Try source activate tensorflow.
On mac and in some windows environments source activate <env_name> is required. activate <env_name> is used instead in some Windows' environments.
For example, on Windows, if you're in a Git Bash terminal window, you must use source activate <env_name>, but if you're in a Powershell terminal window, then activate <env_name> would be required.
Linux/Mac will always (so far as I know) require source activate <env_name>
Run Anaconda Prompt as an administrator
I just have the same problem and by this way it's fixed.

Resources