在調用另一個腳本時出現問題,通過調用python main.py(然後調用test3.py ),但是當我通過Web服務器做它給下面的錯誤是神祕的爲什麼我不能通過網絡服務器使用子進程模塊執行另一個python腳本
我不能把這個(TEST3只是打印...)
#proc = subprocess.Popen(['python', 'test3.py'], stdout=subprocess.PIPE)
但能正常工作
proc = subprocess.Popen(['ls', '-la'], stdout=subprocess.PIPE)
錯誤日誌中/var/log/httpd-error.log在FreeBSD
[Thu Mar 01 12:26:55 2012] [error] [client 64.102.194.61] Traceback (most recent call last):
[Thu Mar 01 12:26:55 2012] [error] [client 64.102.194.61] File "/usr/local/www/apache22/data/main2.py", line 22, in <module>
[Thu Mar 01 12:26:55 2012] [error] [client 64.102.194.61]
[Thu Mar 01 12:26:55 2012] [error] [client 64.102.194.61] proc = subprocess.Popen(['python', 'test3.py'], stdout=subprocess.PIPE)
[Thu Mar 01 12:26:55 2012] [error] [client 64.102.194.61] File "/usr/local/lib/python2.7/subprocess.py", line 679, in __init__
[Thu Mar 01 12:26:55 2012] [error] [client 64.102.194.61]
[Thu Mar 01 12:26:55 2012] [error] [client 64.102.194.61] errread, errwrite)
[Thu Mar 01 12:26:55 2012] [error] [client 64.102.194.61] File "/usr/local/lib/python2.7/subprocess.py", line 1228, in _execute_child
[Thu Mar 01 12:26:55 2012] [error] [client 64.102.194.61]
[Thu Mar 01 12:26:55 2012] [error] [client 64.102.194.61] raise child_exception
[Thu Mar 01 12:26:55 2012] [error] [client 64.102.194.61] OSError
[Thu Mar 01 12:26:55 2012] [error] [client 64.102.194.61] :
[Thu Mar 01 12:26:55 2012] [error] [client 64.102.194.61] [Errno 2] No such file or directory
[Thu Mar 01 12:26:55 2012] [error] [client 64.102.194.61]
[Thu Mar 01 12:26:55 2012] [error] [client 64.102.194.61] File does not exist: /usr/local/www/apache22/data/favicon.ico
這就是它!我錯過了這個B/C我雖然我的路徑已經是正確的(我可以在控制檯上鍵入python並且python出現),但是它對於web服務器確實不正確!不知道這是如何不同,我將不得不做一些閱讀。建議在FreeBSD上做這件事很有幫助。我的路徑實際上是FreeBSD上的/ usr/local/bin/python!作品像一個魅力...我打字這麼長的B/C它不會讓我點擊複選標記呢.... 20秒...好吧,讓我們這樣做 – 2012-03-01 17:48:38