我编写了非常小的脚本并尝试捕获脚本的输出。我曾多次以类似的方式写过,但从未遇到过问题。我可以输入。我认为我犯了一个非常愚蠢的错误
numpy_temp = """
import numpy
import sys
a, b, c = numpy.polyfit(%s,%s, 2)
print a, b, c""" %(x, y)
fp_numpy = open("numpy_temp.py", "w")
fp_numpy.write(numpy_temp)
cmd = "/remote/Python-2.7.2/bin/python numpy_temp.py "
proc = subprocess.Popen(cmd, stdout = subprocess.PIPE,
stderr = subprocess.PIPE, shell = True)
out, err = proc.communicate()
print "out", out