我必须在Ubuntu中调用一个可执行文件......刚刚学会了如何在Windows中使用subprocess.Popen
来完成这项工作。现在,我需要在Ubuntu中重复这一步。调用一个子进程
我已经使用了下面的Python命令:
a=subprocess.Popen("filename.exe",shell=0)
回报是
Traceback (most recent call last):
File "/untitled0.py", line 29, in <module>
a=subprocess.Popen("filename.exe",shell=0)
File "/usr/lib/python2.7/subprocess.py", line 679, in __init__
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1249, in _execute_child
raise child_exception
OSError: [Errno 8] Exec format error
如果我改变shell=1
,有没有投诉,但没有输出文件要么产生。
我已经检查此文件的使用file filename.exe
它返回的类型:
文件名.exe:ELF 64位LSB的可执行文件,X86-64,版本1(SYSV) 动态链接(使用共享库),为GNU/Linux 2.6.9,不 剥离
所以是有可能在Ubuntu使用subprocess.Popen
称呼它?
你试图在32位主机上运行64位二进制文件吗?你可以显示'uname -a'的输出吗? –
这看起来像我的Ubuntu是32位,这可能会导致我的问题..我可以知道什么是uname -a? –
这是一个打印有关主机信息的命令,包括操作系统,主机名,内核版本,内核编译时间和体系结构(从中可以知道它是否是a)。在我的32位笔记本电脑上,它打印出“Linux redance 2.6.26-2-686#1 SMP Thu Jan 27 00:28:05 UTC 2011 i686 GNU/Linux',而在我的64位服务器上打印'Linux red 2.6。 32-5-amd64#1 SMP Mon Jan 16 16:22:28 UTC 2012 x86_64 GNU/Linux'。 –