可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
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?
回答1:
You need to add that folder to your Windows Path:
回答2:
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.
>>>
回答3:
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...
回答4:
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.
回答5:
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
Then execute the Python command using the full path name to make sure that works.
回答6:
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
回答7:
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.
回答8:
Type py -v instead of python -v in command prompt
回答9:
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 %PATH% you'll see your python part in the end. Hence now python is accessible. From this tutorial
回答10:
i solved this by running CMD in administration mode, so try this.