问题
I am currently working with a Windows XP Computer at my school. My question is on how to find the exact path variable to run Python in the command line. I have tried multiple directories but they all keep displaying "'python' is not recognized as an internal or external command, operable program or batch file." Is there an easy way to find this?
回答1:
If the installation is ok. You can use python, opening the command prompt window and navigating to your Python installation directory (default is C:\Python27
). Type python from this location to launch the Python interpreter.
Microsoft Windows [Version 6.2.9200]
(c) 2012 Microsoft Corporation. All rights reserved.
C:\Users\Username> cd C:\Python27
C:\Python27> python
Python 2.7.8 (default, Jun 30 2014, 16:03:49) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>
Another way you can follow an Installation tutorial.
You can run Python from any location without having to constantly reference the full installation pathname.
This can be done by adding the Python installation path to Windows' PATH
ENVIRONMENT VARIABLE
*In Windows 7 and Windows 8, simply searching for "environment variables" will present the option to Edit the system environment variables
. This will open the System Properties / Advanced
tab
*In Windows XP, right-click on My Computer->Properties
to open System Properties
and click on the Advanced
tab.
On the
System Properties / Advanced
tab, clickEnvironment Variables
to openUser Variables
andSystem Variables
Create a new
System Variable
named Variable name:PYTHON_HOME
and Variable value:c:\Python27
(or whatever your installation path was)Find the system variable called
Path
and clickEdit
Add the following text to the end of the Variable value:
;%PYTHON_HOME%\;%PYTHON_HOME%\Scripts\
Verify a successful environment variable update by opening a new command prompt window (important!) and typing
python
from any location.
来源:https://stackoverflow.com/questions/47140580/python-path-directory