SSIS 执行流程任务 Python 脚本
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/43873544/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
SSIS Execute Process Task Python script
提问by Elad L.
I'm trying to execute a python scrip from SSIS Execute Process Task. I followed all the tutorials of how to do this an still the script is failing from the start. when i execute the python script out of SSIS it runs perfectly.
我正在尝试从 SSIS 执行进程任务执行 python 脚本。我遵循了有关如何执行此操作的所有教程,但脚本从一开始就失败了。当我从 SSIS 执行 python 脚本时,它运行得很好。
This is my Python scrip:
这是我的 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")
this is an image of the SSIS Execute Process Task:
这是 SSIS 执行流程任务的图像:
error message:
错误信息:
[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".
回答by ZBlaze
Did you have spaces in your file path to your python script? I had the same error when trying to pass a path with spaces as my argument in Execute Script Process. The resolution was to enter the argument with quotes.
你的python脚本的文件路径中有空格吗?在执行脚本过程中尝试传递带有空格的路径作为我的参数时,我遇到了同样的错误。决议是用引号输入参数。
回答by Anton Arkhipkin
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.
当过程从启动Execute Process Task
SSIS包的一步,它不是从同一个文件夹中的可执行文件(运行.bat
,.py
,.exe
位于等等)。与直接文件执行有何不同。如果您的可执行文件与同一文件夹中的其他一些文件一起工作,它可能尤其重要。
So, it is necessary additionally specify working folder property of Execute Process Task
step of SSIS Package.
因此,有必要额外指定Execute Process Task
SSIS 包步骤的工作文件夹属性。
On your screenshot Working directoryproperty value is empty. Put there the
C:\Users\bla\blalba\bla\gender-guesser-0.4.0\test\
在您的屏幕截图上,工作目录属性值为空。放在那里
C:\Users\bla\blalba\bla\gender-guesser-0.4.0\test\