我试图从SSIS执行进程任务执行python脚本。我按照所有教程如何执行此操作仍然是脚本从一开始就失败了。当我从SSIS执行python脚本时,它运行得很好。
这是我的Python脚本:
import sys
import gender_guesser.detector as gender
import xml.etree.cElementTree as ET
from xml.etree.ElementTree import ParseError
try:
input("Press Enter to continue...")
except SyntaxError:
pass
tree = ET.parse('user.xml')
root = tree.getroot()
for child_of_root in root:
for attr in child_of_root:
if attr.tag == 'first_name':
upperName = "%s%s" % (attr.text[0].upper(), attr.text[1:])
print attr.tag,upperName
d = gender.Detector()
gen = d.get_gender(upperName)
print gen
attr.text= gen
tree = ET.ElementTree(root)
tree.write("user1.xml")
这是SSIS执行流程任务的图像:
错误消息:
[Execute Process Task] Error:
In Executing "C:\Python27\python.exe" "C:\Users\bla\blalba\bla\gender-guesser-0.4.0\test\genderTest.py " at "", The process exit code was "1" while the expected was "0".
答案 0 :(得分:8)
你的python脚本文件路径中是否有空格?尝试在Execute Script Process中传递带空格的路径作为我的参数时,我遇到了同样的错误。决议是用引号输入参数。
答案 1 :(得分:1)
When the process is launched from Execute Process Task
step of SSIS Package, it's not being run from the same folder as the executable file (.bat
, .py
, .exe
and so on) located.
What is different from the direct file execution.
And it can be especial critical in case when your executable file working with some other files in the same folder.
So, it is necessary additionally specify working folder property of Execute Process Task
step of SSIS Package.
On your screenshot Working directory property value is empty. Put there the
C:\Users\bla\blalba\bla\gender-guesser-0.4.0\test\