我必須同意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位程序正在執行。 –