I have a python script that works fine when I run it in an IDE. If I execute it from a command line, I have to be in the directory in which is resides in order for it to run properly. If I try to run it as an agent job or with an Execute Process Task in SSIS it fails.
The script inside the agent job looks like this:
py E:\Opt\AppDirectory\foo.py
SET EXITCODE = %ERRORLEVEL%
IF %EXITCODE% EQ 0 (
REM Script Ran Sucessfully
EXIT 0
)
IF %EXITCODE% EQ 1 (
REM Script Error
EXIT 1
)
When I run this, or in SSIS, I get:
Traceback (most recent call last):
File "E:\Opt\AppDirectory\foo.py", line 76, in <module>
encoder = jl.load('model.joblib')
File "C:\ProgramData\Anaconda3\lib\site-packages\joblib\numpy_pickle.py", line
590, in load
with open(filename, 'rb') as f:
FileNotFoundError: [Errno 2] No such file or directory: 'model.joblib'
model.joblib lives in the exact same directory as foo.py. It's really weird when it says it can't find the file, but I'm staring right at it.
The job can find foo.py. Why can't it seem to find model.joblib?