Python Path Directory

≯℡__Kan透↙ 提交于 2020-12-12 12:00:30

问题


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.

  1. On the System Properties / Advanced tab, click Environment Variables to open User Variables and System Variables

  2. Create a new System Variable named Variable name: PYTHON_HOME and Variable value: c:\Python27 (or whatever your installation path was)

  3. Find the system variable called Path and click Edit

  4. Add the following text to the end of the Variable value: ;%PYTHON_HOME%\;%PYTHON_HOME%\Scripts\

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!