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

PythonCmd

Python Problem Overview


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?

Python Solutions


Solution 1 - Python

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.
> >>>

Solution 2 - Python

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

Solution 3 - Python

You need to add that folder to your Windows Path:

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

Solution 4 - Python

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

Solution 5 - Python

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

Solution 6 - Python

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

Solution 7 - Python

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

Solution 8 - Python

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

Solution 9 - Python

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

Solution 10 - Python

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

Solution 11 - Python

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.

Solution 12 - Python

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.

Solution 13 - Python

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.

Solution 14 - Python

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

Solution 15 - Python

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.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionDave StallbergView Question on Stackoverflow
Solution 1 - PythonAsif IqbalView Answer on Stackoverflow
Solution 2 - PythonAkhileshView Answer on Stackoverflow
Solution 3 - PythonDarrell O'DonnellView Answer on Stackoverflow
Solution 4 - PythonsnrView Answer on Stackoverflow
Solution 5 - PythonGufran HasanView Answer on Stackoverflow
Solution 6 - PythonSashJKView Answer on Stackoverflow
Solution 7 - PythonKarim Mokhtar MohamedView Answer on Stackoverflow
Solution 8 - PythonAbdus Salam AzadView Answer on Stackoverflow
Solution 9 - PythonKe DuView Answer on Stackoverflow
Solution 10 - PythonBlack MambaView Answer on Stackoverflow
Solution 11 - PythoniheanyiView Answer on Stackoverflow
Solution 12 - PythonKevinView Answer on Stackoverflow
Solution 13 - Pythonrun_the_raceView Answer on Stackoverflow
Solution 14 - PythonSapnaView Answer on Stackoverflow
Solution 15 - PythonJamieView Answer on Stackoverflow