【发布时间】:2018-01-11 10:27:58
【问题描述】:
我正在尝试从主脚本调用 python 脚本。我只需要从主脚本中生成一个数据帧,然后将其作为要在子进程中使用的参数传递给子进程脚本。
以下是我尝试编写所需的 python 主脚本。
from subprocess import PIPE, Popen
import pandas as pd
test_dataframe = pd.read_excel(r'C:\test_location\file.xlsx',sheetname='Table')
sp = Popen(["python.exe",'C:/capture/test.py'], shell=True, stdin=PIPE, stdout=PIPE, stderr=PIPE)
sp.communicate(test_dataframe)
这是错误:
TypeError: argument 1 must be convertible to a buffer, not DataFrame
这是我第一次尝试使用 subprocess 模块,所以我还不是很擅长。任何帮助将不胜感激。
【问题讨论】:
标签: python pandas dataframe subprocess