简体   繁体   中英

SQL Job Fails on Python call in Powershell Script

I have a powershell script that I'd like to run as a SQL Agent Job.

It contains 3 lines:

Invoke-SqlCmd... Copy-Item... python...

The first 2 lines work flawlessly, however the job fails on the third line in which I call some python.

The powershell script works fine when run manually from the powershell ISE. I assume, and this appears to be the case from some googling that the SQL Agent doesn't like or can't run python on its own, however I would have assumed that since its all part of a powershell script I would get around that problem.

The SQL job error is:

Executed as user: DOMAIN\SQL_ReportServer. A job step received an error at line 3 in a PowerShell script. The corresponding line is 'python StripQuotes.py "E:\DW_Exports\Pearsonvue\CDD.txt"'. Correct the script and reschedule the job. The error information returned by PowerShell is: 'The term 'python' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.  '.  Process Exit Code -1.  The step failed.

Is there anyway to get this process working?

The term 'python' is not recognized as the name of a cmdlet, function, script file, or operable program.

python is not visible in the PATH for the context of the SQL Server Agent or powershell proxy account. Try invoking python using the fully qualified pathname (eg C:\Python37\python.exe ). You may encounter further errors which you should then debug as new and separate problems.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM