2013-01-10 43 views
2

我想通過使用os.system或subprocess.call或任何其他程序,通過python運行程序,但該程序是一個32位程序,我的python是64位,無法找到該程序爲了運行它。通過python運行程序最簡單的方法是什麼?使用python 64bit運行32位程序

一些更多的細節: 我使用ubuntu,運行python 2.7,安裝了ia32-libs(程序完美地從命令行運行),使用idle運行python。

謝謝!

=============(當天晚些時候)=============

好,知道了。問題是隻使用IDLE時(dono爲什麼)。使用其他guis(鐵python,eclipse)不會返回錯誤。

謝謝大家。

回答

1
subprocess.call("command param1 param2", shell=True) 

適合我。你確定它是一個32/64位的問題?

+0

我確定。你的建議是不工作,並返回錯誤代碼127(如果該文件不存在),並相信我我檢查了路徑... – elikbelik

+0

作爲Arne也不能重現你的問題,也許你真的面臨一個PATH問題?你有沒有嘗試過使用絕對路徑?如果它不起作用,它會讓我感到意外,因爲'subprocess.call'會打開一個全新的shell,它運行在一個單獨的進程中,因此不會以任何方式鏈接到您的64位Python。在這個shell中,32位程序正在執行。 –

0

我必須同意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/ 

你可以提供一個失敗的例子代碼?

相關問題