1

I have a python program which in turn calls an R script for doing some calculations. This worked great till I switched over to UNC. I am on Windows and I tried all that has been suggested on StackOverflow but I still keep getting an error saying "base package can't be opened"

I have tried with backward slashes meaning on the lines of \\server/abc/a.exe etc as well as \\server\abc\a.exe

What am I missing? It seems the problem is that the executable can't have a UNC path , in this case the variable rscriptpath. I really need that to be a UNC as the caller program would not in the same server. Thanks in advance.

import  subprocess


Date='2018-03-01'
env='PROD'
main_dir=r'\\sandbox0968\QRMPortfolioRisk\QRMPortfolioRisk'
rscriptpath = r'\\sandbox0968\bin\Rscript.exe'
dailymain = r'\\sandbox0968\QRMPortfolioRisk\QRMPortfolioRisk\src\daily\DailyMain_cmd.R'
dailymainstatic = r'\\sandbox0968\QRMPortfolioRisk\QRMPortfolioRisk\src\daily\DailyMainStatic.R'
cxo_script = r'\\sandbox0968\QRMPortfolioRisk\QRMPortfolioRisk\src\daily\CXOdump.R'
calc_dir = r'\\sandbox0968\QRMPortfolioRisk\QRMPortfolioRisk\data\calculations'
reestimate = r'\\sandbox0968\QRMPortfolioRisk\QRMPortfolioRisk\src\estimation\EstimationMain_cmd.R'
#
subprocess.check_call([rscriptpath, '--vanilla', dailymain, str(Date), str(main_dir), env])
Saugat Mukherjee
  • 778
  • 8
  • 32
  • Have you tried executing your command from Command Prompt and if it works - can you paste it verbatim here? – zwer Apr 24 '18 at 23:36
  • @zwer I get this error: Fatal error: unable to open the base package Traceback (most recent call last): File "C:\Program Files\Anaconda3\lib\subprocess.py", line 581, in check_call raise CalledProcessError(retcode, cmd). subprocess.CalledProcessError: Command returned non-zero exit status 2 – Saugat Mukherjee Apr 25 '18 at 06:35
  • I'm not asking for the error from Python but rather can you make it run manually from the Command Prompt itself and, if so, what command did you use? – zwer Apr 25 '18 at 13:13
  • Not sure I follow, the subprocess.Check_call is a python command and it is trying to execute an R script using the Rscript.exe and that path is the problem. the other like the main_dir in my code above is ok as because as soon as I change it to a local directory it works. I ran it from the command prompt but I have to use the Python interpretor to run this and thus when I run it from cmd using python, it gives me a file can't be found error. I am now thinking on the lines of my caller function creating a trigger file on this python box and then a scheduled job on that box will trigger this. – Saugat Mukherjee Apr 25 '18 at 18:15

0 Answers0