Python路径目录 [英] Python Path Directory

查看:57
本文介绍了Python路径目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在学校使用Windows XP计算机.我的问题是如何找到确切的路径变量以在命令行中运行Python.我尝试了多个目录,但它们都一直显示'python'不被识别为内部或外部命令,可操作程序或批处理文件".有一个简单的方法可以找到这个吗?

解决方案

如果安装正常.您可以使用python,打开命令提示符窗口并导航到您的Python安装目录(默认为 C:\ Python27 ).从该位置键入python以启动Python解释器.

  Microsoft Windows [版本6.2.9200](c)2012年,微软公司.版权所有.C:\ Users \ Username>CD C:\ Python27C:\ Python27>Python在Win32上使用Python 2.7.8(默认值,2014年6月30日,16:03:49)[MSC v.1500 32位(Intel)]键入帮助",版权",信用".或许可证"想要查询更多的信息.>>> 

您可以按照另一种方式进行安装教程.

您可以从任何位置运行Python,而不必不断引用完整的安装路径名.

这可以通过将Python安装路径添加到Windows的 PATH 环境变量
来完成.* 在Windows 7和Windows 8中,只需搜索环境变量"即可.将显示用于编辑系统环境变量的选项.这将打开系统属性/高级标签
* 在Windows XP中,右键单击我的电脑->属性以打开系统属性,然后单击 Advanced 选项卡.

  1. 在"<代码>系统属性/高级"选项卡上,单击"<代码>环境变量"以打开"<代码>用户变量"和"<代码>系统变量

  2. 创建一个新的 System Variable ,名称为Variable name: PYTHON_HOME 和Variable value: c:\ Python27 (或您安装的任何版本)路径是)

  3. 找到名为 Path 的系统变量,然后单击 Edit

  4. 在变量值的末尾添加以下文本:;%PYTHON_HOME%\;%PYTHON_HOME%\ Scripts \

  5. 通过打开新的命令提示符窗口(重要!)并在任意位置键入 python 来验证环境变量更新是否成功.

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?

解决方案

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.

这篇关于Python路径目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆