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