简体   繁体   English

在Windows中运行python脚本

[英]Run a python script in windows

I have always used a mac to write and run python scripts. 我一直使用Mac来编写和运行python脚本。 However, I have a bunch of files on a PC that I need to run a script on. 但是,我在PC上有一堆文件,需要在上面运行脚本。 I have never really used a PC and don't know how to run the script. 我从未真正使用过PC,也不知道如何运行脚本。

If I go to the command program on the PC and type in python , nothing happens. 如果我转到PC上的command程序并输入python ,则什么都不会发生。 How do I find where the python path is in order to get into the python prompt ? 如何找到python路径在哪里,以便进入python prompt Also, once I am in the prompt, is the importing of modules the same as in a Unix system? 另外,一旦出现提示, modules的导入是否与Unix系统中的相同?

Python isn't added to the system environment's PATH variable by default on windows. Windows上默认情况下不将Python添加到系统环境的PATH变量中。 You have to either add the path to the directory containing the Python.exe file to the PATH variable, or call python explicitly. 您必须将包含Python.exe文件的目录的路径添加到PATH变量,或显式调用python。

This issue has been addressed in the Python documentation: Python Documentation: # How to run a Python program under windows Python文档中已解决此问题: Python文档:#如何在Windows下运行Python程序

Assuming Python is installed, it is usually placed in a folder prefixed with "Python" and the major/minor version. 假设已安装Python,通常将其放置在前缀为“ Python”和主要/次要版本的文件夹中。 Eg C:\\Python26 例如C:\\Python26

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM