0

I have a SQL Server Agent job that executes some python scripts using CmdExec. Everything is set up with a proxy account as expected.

When I run the job I get:

Message Executed as user: domain\proxyaccount. 'python' is not recognized as an internal or external command, operable program or batch file. Process Exit Code 1. The step failed.

I'm using Anaconda and Python is in the system PATH variable. When I run python from command line, it works. When I run python cutting and pasting the specific command from the job, it works. When I use runas to mimic the proxy account it works. The only place Python doesn't run is form inside the job.

What else do I need to look at to trouble shoot this issue?

Bob Wakefield
  • 3,739
  • 4
  • 20
  • 30
  • Did you restart SQL Server Agent after you installed Python? It is necessary, so it will load new environment variables. There are also suggestions to restart SQL Server too, but I believe restarting SQL Server Agent will be enough – Sergey Nudnov Apr 21 '19 at 04:40
  • Thank you! I'll try that and let you know how it works. – Bob Wakefield Apr 21 '19 at 06:39
  • I'm not sure if that fixed it or not. There is a new error and I'm not sure if it's related. I'll report back and finalize this post when I've got it totally solved. – Bob Wakefield Apr 21 '19 at 14:25
  • I have put it as my answer. For the new problems we could review them too. I believe, once a struggle point is over, it will be resolved quickly. :) – Sergey Nudnov Apr 21 '19 at 16:32
  • Bob, If I was able to help you, I would appreciate you marking my answer as accepted. – Sergey Nudnov Apr 24 '19 at 01:32

1 Answers1

1

You should restart SQL Server Agent after you installed Python on the server.

It is necessary for SQL Server Agent to load new environment variables, including the updated PATH with Python in it.

There are also suggestions to restart SQL Server too, but I believe restarting SQL Server Agent will be enough.

Sergey Nudnov
  • 1,327
  • 11
  • 20