【发布时间】:2016-06-02 00:01:30
【问题描述】:
让我们考虑一下我需要执行一个名为 smart.exe 的程序的 Linux 平台,该程序使用 input.dat 文件。两个文件都放在同一个目录下,每个文件的文件权限都是777。
现在,如果我在终端窗口中运行以下命令,smart.exe 将完全执行,没有任何错误。
$./smart.exe input.dat
另一方面,如果我使用位于同一目录中的名为 my_script.py 的以下 python 脚本,则会出现错误。
my_script.py 有以下代码:
#!/usr/bin/python
import os, subprocess
exit_code = subprocess.call("./smart.exe input.dat", shell = False)
错误如下:
File "my_script.py", line 4, in <module>
exit_code = subprocess.call("./smart.exe input.dat", shell = False)
File "/usr/lib64/python2.6/subprocess.py", line 478, in call
p = Popen(*popenargs, **kwargs)
File "/usr/lib64/python2.6/subprocess.py", line 642, in __init__
errread, errwrite)
File "/usr/lib64/python2.6/subprocess.py", line 1234, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
谁能告诉我为什么会这样。请注意 smart.exe 大约需要 10 秒才能完全完成。这可能是问题的线索。
还请告知是否有任何其他方式可以从 my_script.py 运行 smart.exe。非常感谢您的解决方案!
【问题讨论】:
-
你打算如何在 Linux 机器上运行 Windows 二进制文件?你在使用 WINE 之类的东西吗?
标签: python linux python-2.7