【问题标题】:Make an batch file that runs commando in WinPython Command Prompt在 WinPython 命令提示符中创建一个运行 commando 的批处理文件
【发布时间】:2015-06-29 10:17:25
【问题描述】:

如何编写一个批处理文件来从 WinPython 命令提示符执行命令“python my_program.py”?不是来自 cmd.exe!

【问题讨论】:

  • 1.什么是 WinPython 命令提示符? 2.你是说PythonWin吗? 3. 提示是什么样的?
  • 你可以在这里找到它:winpython.sourceforge.net
  • 列出了几个命令提示符。您是指概览部分中winpython.github.io 的图片中的“WinPython 命令提示符”吗?
  • 是的,这是正确的。

标签: windows batch-file python-3.x


【解决方案1】:

试一试:

"Portable or not, the choice is yours!" 部分中,它描述了如何“将您的发行版注册到 Windows”。
当您在 Windows 中注册 WinPython 时,您可以双击文件并执行。这也意味着您只需在命令提示符(cmd.exe 和其他)中键入文件名my_program.py 即可运行该文件。注意:在 linux 系统上,你可以写 python my_program.py 来告诉 python 运行这个程序。相比之下,在 Windows 上,一旦您注册了扩展程序,您就可以运行它,而无需告诉 Windows 使用哪个解释器。

如果你想为my_program.py使用特定的解释器,你需要指定解释器的路径。
我在C:\WinPython-64bit-3.4.3.3 安装了 WinPython,
所以我的命令是C:\WinPython-64bit-3.4.3.3\scripts\python.bat my_program.py
我还安装了 Python 3,所以我的 python.exe 路径是 C:\Python34\python.exe
我的命令是C:\Python34\python.exe my_program.py

尝试一下,如果它不起作用,请告诉我。

【讨论】:

  • 很好的尝试,但是当我尝试运行代码时它没有找到所有的 lib-packages。 my_program.py 必须在 WinPython 命令提示符下运行才能运行。
  • 您能描述一下您采取的具体步骤、获得的输出以及您在问题中期望的输出吗?
【解决方案2】:

我通过从正常的 python 安装中删除路径解决了这个问题。我还卸载了正常的 python 发行版。我还为 WinPython 中的 python 版本创建了路径。现在我可以使用普通的cmd来运行程序了。 :-)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-09-02
    • 1970-01-01
    • 2011-08-18
    相关资源
    最近更新 更多