1

I have a notebook that I am trying to automatically execute using a batch file, but to do so I need it to launch in the Anaconda prompt. Based on the suggestions from this post, I was able to get the batch file to open it by calling the activate.bat, but it wouldn't run the second part.

@echo on
call %windir%\System32\cmd.exe "/K" C:\Users\mccom\AppData\Local\Continuum\anaconda3\Scripts\activate.bat C:\Users\mccom\AppData\Local\Continuum\anaconda3 
papermill file.ipynb file_out.ipynb

Any tips?

Kbbm
  • 375
  • 2
  • 15
  • 2
    You're not running `papermill file.ipynb file_out.ipynb` in the same instance of cmd.exe as your `activate.bat` is being run. The environment and variables defined within `activate.bat` are therefore undefined once that instance closes, and before that command is invoked. Additionally, the `/K` option is to run the command following it but keep the instance of cmd.exe open until you close it. Your batch file doesn't therefore run `papermill file.ipynb file_out.ipynb` until the `activate.bat` environment is disposed of upon closure. – Compo Feb 01 '20 at 16:46

1 Answers1

1

Based on the Advice of Compo, calling papermill before calling anaconda worked.

@echo on
call C:\Users\mccom\AppData\Local\Continuum\anaconda3\Scripts\activate.bat
call papermill New_Send_Email_Personal.ipynb New_Send_Email_Personal_out.ipynb
pause
Kbbm
  • 375
  • 2
  • 15