pip無法在pypi網站上找到此模塊以及我。 你能告訴我祕密,如何安裝它?如何爲python安裝子進程模塊?
我需要模塊通過subprocess.call產生新的shell進程。我見過很多例子,其中人們使用import subprocess
,但沒有人展示它是如何安裝的。
錯誤,我得到了(以防萬一我失去了我的頭腦,不明白是怎麼回事):
Microsoft Windows [Version 6.3.9600]
(c) 2013 Microsoft Corporation. All rights reserved.
C:\Users\Alexander\Desktop\tests-runner>python run.py
Traceback (most recent call last):
File "run.py", line 165, in <module>
main()
File "run.py", line 27, in main
subprocess.call('py.test')
File "C:\Python27\lib\subprocess.py", line 522, in call
return Popen(*popenargs, **kwargs).wait()
File "C:\Python27\lib\subprocess.py", line 710, in __init__
errread, errwrite)
File "C:\Python27\lib\subprocess.py", line 958, in _execute_child
startupinfo)
WindowsError: [Error 2] The system cannot find the file specified
它的內置,您不必安裝它。你的Python版本是什麼? – 2014-10-01 14:57:48
'subprocess'模塊是標準庫的一部分,它不需要(不能,實際上)安裝。您得到的錯誤表明應該作爲子進程運行的* executable *無法找到,而不是'subprocess'模塊本身。可能是工作目錄「$ PATH」的問題,或者可執行文件不是'.exe'。 – 2014-10-01 15:04:11
什麼類型的文件是'py.test'? Windows不知道它應該如何執行擴展名爲「.test」的文件,所以你至少需要指定一個解釋器來執行它。看到[這個問題](http://stackoverflow.com/questions/4965175/make-subprocess-find-git-executable-on-windows/10555130)爲'git.cmd'這個問題的例子。 – 2014-10-01 15:07:34