如何在 Windows 上运行 python 脚本?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1920997/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-03 23:21:23  来源:igfitidea点击:

How can I run a python script on windows?

pythonide

提问by Vaibhav

Can anyone please tell me an IDE for running python programs? Is it possible to run the program through command line?

谁能告诉我一个用于运行 python 程序的 IDE?是否可以通过命令行运行程序?

回答by Boldewyn

Take a look at ActiveState's ActivePython. It's quite a nice implementation of Python on Windows. Another way is using Cygwin's Python port. These two are Python implementations. I don't use an IDE, I write my Python code in Notepad++.

看看ActiveState 的 ActivePython。这是 Python 在 Windows 上的一个很好的实现。另一种方法是使用Cygwin 的 Python 端口。这两个是 Python实现。我不使用 IDE,我在Notepad++ 中编写我的 Python 代码。

To run a python program after saving it to C:\Users\vaibhav\Code\myscript.py:

保存后运行python程序C:\Users\vaibhav\Code\myscript.py

  1. ActivePython: If I remember right, ActiveState updates the path correctly. So it should be a s simple as:

    • Press "start" in the task bar
    • In the search field search for "cmd"
    • In the appearing box navigate to your folder with the python script: dir Users\vaibhav\Code
    • call python myscript.pyand you're done
  2. Cygwin: After installing Cygwin, you have a full-featured bash terminal on your Windows machine.

    • click on the Cygwin icon on your desktop
    • In the appearing window navigate to the folder with your python script: cd /cygdrive/c/Users/vaibhav/Code
    • type python myscript.py
    • e voila
  1. ActivePython:如果我没记错的话,ActiveState 会正确更新路径。所以它应该很简单:

    • 按任务栏中的“开始”
    • 在搜索字段中搜索“cmd”
    • 在出现的框中,使用 python 脚本导航到您的文件夹: dir Users\vaibhav\Code
    • 打电话python myscript.py,你就完成了
  2. Cygwin:安装 Cygwin 后,您的 Windows 机器上就有了一个功能齐全的 bash 终端。

    • 单击桌面上的 Cygwin 图标
    • 在出现的窗口中,导航到包含您的 Python 脚本的文件夹: cd /cygdrive/c/Users/vaibhav/Code
    • 类型 python myscript.py

回答by argh

IDE for running scripts? You can have any IDE you like, but if you need only to run python scripts you go like this:

用于运行脚本的IDE?你可以拥有任何你喜欢的 IDE,但如果你只需要运行 python 脚本,你可以这样:

python.exe pythonScript.py

python.exe pythonScript.py

回答by extraneon

I like the EasyEclipse for pythondistribution. You'd need to have python and java installed of course.

我喜欢用于 python发行版的EasyEclipse。当然,您需要安装 python 和 java。

回答by luc

PyDev and Komodo Edit are 2 nice Python IDE on Windows.

PyDev 和 Komodo Edit 是 Windows 上两个不错的 Python IDE。

I also like the SciTE text editor very much.

我也非常喜欢 SciTE 文本编辑器。

These 3 solutions make possible to run Python scripts

这 3 个解决方案使运行 Python 脚本成为可能

回答by anmi

I tried to run a Python script with multiprocessing on windows. see this tutorial

我试图在 Windows 上运行带有多处理功能的 Python 脚本。看这个教程

It does not work on Windows, but on raspian it went very well. Thus I knew that it was a Windows problem. I installed cygwin and followed this tutorial Installing Python inside Cygwin.

它在 Windows 上不起作用,但在 raspian 上运行得很好。因此我知道这是一个 Windows 问题。我安装了 cygwin 并按照本教程在 Cygwin 中安装 Python 进行操作

After that I additionally installed numpy with the command easy_install numpyand now i can run python scripts with multiprocessing on windows (from cygwin).

之后,我还使用命令安装了 numpy,easy_install numpy现在我可以在 Windows 上运行带有多处理功能的 python 脚本(来自 cygwin)。