我必须同意Thorsten:这应该很好。我测试了使用它的64位python2.6的Debian的稳定和使用的Xsnow 32位:
$ file $(which python2.6)
/usr/bin/python2.6: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.18, stripped
$ file ~/bin/xsnow
/home/myuser/bin/xsnow: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.8, stripped
[email protected]:~
$ python
Python 2.6.6 (r266:84292, Dec 26 2010, 22:31:48)
[GCC 4.4.5] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import subprocess
>>> subprocess.call("~/bin/xsnow", shell=True)
Xsnow-1.42, December 14th 2001 by Rick Jansen ([email protected])
WWW: http://www.euronet.nl/~rja/Xsnow/
你可以提供一个失败的例子代码?
我确定。你的建议是不工作,并返回错误代码127(如果该文件不存在),并相信我我检查了路径... – elikbelik
作为Arne也不能重现你的问题,也许你真的面临一个PATH问题?你有没有尝试过使用绝对路径?如果它不起作用,它会让我感到意外,因为'subprocess.call'会打开一个全新的shell,它运行在一个单独的进程中,因此不会以任何方式链接到您的64位Python。在这个shell中,32位程序正在执行。 –