【发布时间】:2012-08-26 17:52:14
【问题描述】:
早安,
我遇到了一些问题,即一些 Python 应用程序在 Windows 7 中没有正确调用它们的依赖项。这些应用程序将直接调用它们的 Python 依赖项,而不是作为 python.exe 的参数。相对于改变依赖链中的每个文件先调用python命令,有没有办法直接调用Python文件并正确传递参数,或者这是对Python的错误调用?
注意:我将 python.exe 设置为 .py 文件的默认程序
C:\Users\***>ftype | findstr -i python
Python.CompiledFile="C:\Python27\python.exe" "%1" %*
Python.File="C:\Python27\python.exe" "%1" %*
Python.NoConFile="C:\Python27\pythonw.exe" "%1" %*
C:\Users\***>assoc | findstr -i python
.py=Python.File
.pyc=Python.CompiledFile
.pyo=Python.CompiledFile
.pyw=Python.NoConFile
我写了一个Basic Argument-Parsing Python Script,它将解析一个命令行参数并将其作为问候打印回来。如果参数不存在,则会要求将其作为原始输入输入。先显式调用 Python 而未调用的结果如下所示:
C:\Users\***\Desktop>python input.py --greeting="john"
john
The greeting is: john
C:\Users\***\Desktop>input.py --greeting="john"
None
Give me the greeting. johnrom
The greeting is: johnrom
【问题讨论】:
-
如果limejs通过管道与脚本通信; test whether
a.py | b.pyworks on your OS。如果没有;尝试按照链接中的说明修改注册表。 -
@JFSebastian Pipes 在我的操作系统上工作,而 LimeJS 没有使用 Pipes,它直接从命令行调用文件,如原始帖子的最后一个代码段所示。 >
-
您阅读了链接吗?你了解
a.py | b.py和C:\Python27\python.exe a.py | C:\Python27\python.exe b.py的区别吗?什么是“原帖”?我在您的问题中没有看到任何链接。 -
@J.F.Sebastian 我编辑了原始问题以表明没有发生管道,用我编写的程序替换了专有应用程序,并展示了一个直接从命令行调用它的示例。我希望这可以澄清事情!
-
是的,limejs doesn't use pipes for the script(尽管它确实使用管道(不正确地)调用
git)。如果一切都失败了;编辑update()函数并将sys.executable or "python"添加到命令
标签: shell windows-7 python-2.7