'python' is not recognized as an internal or external command [duplicate]
Asked Answered
C

15

152

So I have recently installed Python Version 2.7.5 and I have made a little loop thing with it but the problem is, when I go to cmd and type python testloop.py I get the error:

'python' is not recognized as an internal or external command

I have tried setting the path but no avail.

Here is my path:

C:\Program Files\Python27

As you can see, this is where my Python is installed. I don't know what else to do. Can someone help?

Coreencorel answered 30/7, 2013 at 17:4 Comment(0)
C
46

You need to add that folder to your Windows Path:

https://docs.python.org/2/using/windows.html Taken from this question.

Crookes answered 30/7, 2013 at 17:6 Comment(0)
O
371

Try "py" instead of "python" from command line:

C:\Users\Cpsa>py
Python 3.4.1 (v3.4.1:c0e311e010fc, May 18 2014, 10:38:22) [MSC v.1600 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>

Orissa answered 9/12, 2014 at 18:17 Comment(6)
Confirmed installed python 3.4.2 recently. py command is registered automatically.Logotype
Works! Why python is no good though a lot of sources say it should be used?Inchoate
odd that py is setup automatically... yet not python ? dafaq? Oh but this answer kind of explains #32742593 - basically py allows you to specify what version of python you want, but f you don't specify anything then it chooses the defaultSvetlana
yeah.. same question.. py works for python 3.5.2 but python doesnt work. my environmetal variables are set correctly. Any reason why?Warder
superb! But, I think in my organization they are not letting me install sklearn through default distribution. I am getting this error Failed to establish a new connection: [Errno 11002] getaddrinfo failed',)': /simple/sklearn/Storied
The py program is installed directly into the Windows folder, so it can always be found. The installer, by default, does not add PATH entries for Python installations, because they clutter the PATH and are not very useful. Some other versions of this question have answers that explain it better.Earthworm
C
112

I have found the answer... click on the installer and check the box "Add python to environment variables" DO NOT uninstall the old one rather click on modify....Click on link for picture...

enter image description here

Chippewa answered 10/9, 2016 at 16:54 Comment(4)
Balle balle! You rock. This worked fantastically. I had to restart Powershell and Command Prompt to see the effect.Insomnolence
With restart worked for me as well. Thank you!Rascally
In case you don't see the Advanced Options try running the Python installer as administrator. Then you would be able to see Advanced Options in the installation process.Extravehicular
This worked for me as well. (Modify and Add Python to the environment variables)Casa
C
46

You need to add that folder to your Windows Path:

https://docs.python.org/2/using/windows.html Taken from this question.

Crookes answered 30/7, 2013 at 17:6 Comment(0)
G
14

If you want to see python version then you should use py -V instead of python -V

C:\Users\ghasan>py -V

Python 3.7.1

If you want to go to python's running environment then you should use py instead of python

C:\Users\ghasan>py

Python 3.7.1 (v3.7.1:260ec2c36a, Oct 20 2018, 14:57:15) [MSC v.1915 64 bit (AMD64)] on win32

Type "help", "copyright", "credits" or "license" for more information.

Here you can run the python program as:

print('Hello Python')

Hello Python

Gamete answered 10/12, 2018 at 13:40 Comment(1)
THANKS! This was my first instinct, but just to be sure, I googled "check python version". Everything came up with "python -V". Its been here the whole time. I just removed and added path variables -- who knows what I mistakenly corrupted along the way -- for no reason at all.Luff
S
12

Firstly, be sure where your python directory. It is normally in C:\Python27. If yours is different then change it from the below command.

If after you install it python still isn’t recognized, then in PowerShell enter this:

[Environment]::SetEnvironmentVariable("Path", "$env:Path;C:\Python27", "User")

Close PowerShell and then start it again to make sure Python now runs. If it doesn’t, restart may be required.

enter image description here

Shower answered 24/6, 2016 at 7:39 Comment(1)
Thanks, this helped me add Python 2.7 as "python" (already able to start Python 3 with "py").Rearrange
S
11

Type py -v instead of python -v in command prompt

Sexagenary answered 8/1, 2018 at 7:31 Comment(1)
This works for me. The python directory is my paths, but python does not work for me in PS. It works in git-bash and cmd, though.Ondrej
U
9

i solved this by running CMD in administration mode, so try this.

Urmia answered 2/3, 2018 at 8:28 Comment(0)
M
6

Open CMD with administrative access(Right click then run as administrator) then type the following command there:

set PYTHONPATH=%PYTHONPATH%;C:\My_python_lib

Replace My_python_lib with the folder name of your installed python like for me it was C:\python27. Then to check if the path variable is set, type echo %PATH% you'll see your python part in the end. Hence now python is accessible. From this tutorial

Mutual answered 30/1, 2018 at 18:1 Comment(0)
S
6

I have installed python 3.7.4. First, I tried python in my command prompt. It was saying that 'Python is not recognized command......'. Then I tried 'py' command and it works.

My sample command is:

py hacker.py
Steffi answered 15/7, 2019 at 10:39 Comment(0)
B
4

I have met same issue when I install Python, and it is resolved when I set a PATH in system, here are the steps.

  • Navigate to "Control Panel" -> "System"
  • Click "Advanced system settings" on the left
  • Click "Environment Variables"
  • Search and click "Path" variable
  • Click "Edit"
  • Add "C:\"to the environment variables field, if you are using Windows7, then separate it by a semicolon from the existing entry. If you are using Windows10, just simply click "New" to add.
  • Reopen the Command Prompt and try enter image description here
Blair answered 2/5, 2017 at 15:52 Comment(2)
You can also use SETX PATH "PATHLOCATION OF TOOL" in CMD. e.g. SETX PATH "%USERPROFILE%\AppData\Local\Programs\Python\PythonXX"Guffaw
In sixth step, you should say Add "C:\Python34" or "C:\Python27", it is depended by the version of your pythonMunos
W
1

Option 1 : Select on add environment var during installation Option 2 : Go to C:\Users-> AppData (hidden file) -> Local\Programs\Python\Python38-32(depends on version installed)\Scripts Copy path and add to env vars path.

For me this path worked : C:\Users\Username\AppData\Local\Programs\Python\Python38-32\Scripts

Wheelsman answered 26/10, 2019 at 5:15 Comment(0)
S
0

From the Python docs, set the PATH like you did as above.

You should arrange for Python’s installation directory to be added to the PATH of every command window as it starts. If you installed Python fairly recently then the command dir C:\py* will probably tell you where it is installed; the usual location is something like C:\Python27. Otherwise you will be reduced to a search of your whole disk

Use Tools ‣ Find or hit the Search button and look for “python.exe”. Supposing you discover that Python is installed in the C:\Python27 directory (the default at the time of writing), you should make sure that entering the command

Then execute the Python command using the full path name to make sure that works.

Shabbygenteel answered 30/7, 2013 at 17:9 Comment(0)
B
0

Another helpful but simple solution might be restarting your computer after doing the download if Python is in the PATH variable. This has been a mistake I usually make when downloading Python onto a new machine.

Buckling answered 10/8, 2017 at 16:37 Comment(1)
on windows 10 try, py --version to check python installationSidwohl
J
0

If you uninstalled then re-installed, and running 'python' in CLI, make sure to open a new CMD after your installation for 'python' to be recognized. 'py' will probably be recognized with an old CLI because its not tied to any version.

Jermainejerman answered 1/8, 2019 at 12:48 Comment(0)
H
0

It was a bit more confusing with the Python instructions once SQL Server 2019 was installed with Python. The actual path I find is as follows:

C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64

Scripts run with an Execute command:

Declare @script nvarchar(max)=N'print(11-2)' execute sp_execute_external_script @language = N'Python', @script = @script

There is additional documentation in reference to SQL 2019's version of Python. There is a statement that recommends PIP be used only from a download of sqlmutils-x.x.x.zip located on git (https://www.github.com/Microsoft/sqlmutils) But there is a caveat. Currently this only works for R and not for Python (Anaconda and consequently pip). Python over SQL works but pip is not yet available. (11/25/2019)

Would be great to get an update when this occurs.

Harmony answered 25/11, 2019 at 14:38 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.