64

I am trying to run python from the windows command prompt (windows 10). So the result is the typical one when the path environment variable is not configured

 c:\windows\system32>python
'python' is not recognized as an internal or external command, operable
 program or batch file

however, I am not sure which is the right directory I should set up in the path variable.

I tried a few variations, and none of them work, including:

c:\users\xxx\anaconda3
c:\users\xxx\anaconda3\Scripts
c:\users\xxx\anaconda3\libs\python34

and none of them works.

Does anyone have experience with this particular system constellation (windows, anaconda). Thanks.

Alejandro Simkievich
  • 3,512
  • 4
  • 33
  • 49

12 Answers12

43

it turns out I was mistaken.

Solution is: in anaconda (as well as in other implementations), set the path environment variable to the directory where 'python.exe' is installed.

As a default, the python.exe file in anaconda is in:

c:\.....\anaconda

after you do that, obviously, the python command works, in my case, yielding the following.

python
Python 3.4.3 |Anaconda 2.2.0. (64|bit)|(default, Nov 7 2015), etc, etc
Alejandro Simkievich
  • 3,512
  • 4
  • 33
  • 49
24

Instead of giving the path following way:

C:\Users\User_name\AppData\Local\Continuum\anaconda3\python.exe

Do this:

C:\Users\User_name\AppData\Local\Continuum\anaconda3\
Tshilidzi Mudau
  • 7,373
  • 6
  • 36
  • 49
KAMLESH KARKI
  • 388
  • 3
  • 9
12

The default location for python.exe should be here: c:\users\xxx\anaconda3 One solution to find where it is, is to open the Anaconda Prompt then execute:

> where python

This will return the absolute path of locations of python eg:

(base) C:\>where python
C:\Users\Chad\Anaconda3\python.exe
C:\ProgramData\Miniconda2\python.exe
C:\dev\Python27\python.exe
C:\dev\Python34\python.exe
4

C:\Users\\Anaconda3

I just added above path , to my path environment variables and it worked. Now, all we have to do is to move to the .py script location directory, open the cmd with that location and run to see the output.

Piyush Upadhyay
  • 427
  • 4
  • 12
4

You can also run conda init as below,

C:\ProgramData\Anaconda3\Scripts\conda init cmd.exe

or

C:\ProgramData\Anaconda3\Scripts\conda init powershell

Note that the execution policy of powershell must be set, e.g. using Set-ExecutionPolicy Unrestricted.

Telcrome
  • 361
  • 2
  • 14
Matt
  • 41
  • 1
3
C:\Users\<Username>\AppData\Local\Continuum\anaconda2

For me this was the default installation directory on Windows 7. Found it via Rusy's answer

fivef
  • 2,397
  • 21
  • 21
3

In Windows 10, you may find it here:

C:\Users\\[USER]\AppData\Local\conda\conda\envs\\[ENVIRONMENT]\python.exe

or

C:\ProgramData\Anaconda3

Joyanta J. Mondal
  • 888
  • 1
  • 8
  • 20
Arman Fatahi
  • 2,635
  • 3
  • 24
  • 37
2

To export the exact set of paths used by Anaconda, use the command echo %PATH% in Anaconda Prompt. This is needed to avoid problems with certain libraries such as SSL.

Reference: https://stackoverflow.com/a/54240362/663028

prusswan
  • 6,853
  • 4
  • 40
  • 61
2

I want to mention that in some win 10 systems, Microsoft pre-installed a python. Thus, in order to invoke the python installed in the anaconda, you should adjust the order of the environment variable to ensure that the anaconda has a higher priority.

V

HZ-VUW
  • 842
  • 9
  • 20
  • You can delete the python.exe in the %USERPROFILE%\AppData\Local\Microsoft\WindowsApps folder. It has 0 kb size and you can safely delete it. Then add c:\users\xxx\anaconda3 path to your path variable and it should work. – hru_d Jan 29 '21 at 05:31
  • this was my issue as well. I just removed the whole `...\WindowsApps` entry. It is only muddying the path. – Flame Apr 28 '21 at 16:02
2

Try path env var for the system (on Windows)

C:\ ...\Anaconda3\

C:\ ...\Anaconda3\scripts

C:\ ...\Anaconda3\Library\bin

Must solve! It worked for me.

Joyanta J. Mondal
  • 888
  • 1
  • 8
  • 20
0

You could also just re-install Anaconda, and tick the option add variable to Path.. This will prevent you from making mistakes when editing environment variables. If you make mistakes here, your operating system could start malfunctioning.

Psychotechnopath
  • 2,471
  • 5
  • 26
  • 47
0

Provide the Directory/Folder path where python.exe is available in Anaconda folder like

C:\Users\user_name\Anaconda3\

This should must work.

Sunil Singh
  • 187
  • 2
  • 12