14

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.

This is my Python scrip:

 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:

this is an image of the SSIS Execute Process Task

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".
2
  • Do you get any error message? The space before import sys is a problem, unless it only occured when you pasted the code here on SO Commented May 9, 2017 at 15:11
  • yes, sorry I forgot to add it. this is the message: The process exit code was "1" while the expected was "0". Commented May 9, 2017 at 15:16

2 Answers 2

19

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.

Sign up to request clarification or add additional context in comments.

Comments

5

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\

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.