Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using a .bat to change directories and run Jupyter

I'm new to coding but I simply want to change directory and run jupyter. The problem is cmd instantly closes once it reaches the jupyter notebook command. Tried cmd /k too but it doesn't have an effect. I must being doing this wrong.

F:
cd directoryname
activate environmentname
jupyter notebook
pause

Solution: The commands were closing the prompt for some reason when executed in a .bat (they don't when typed). The fix was to type call before the commands.

F:
cd directoryname
call activate environmentname
call jupyter notebook
pause
like image 689
Jubei Avatar asked Feb 21 '16 21:02

Jubei


People also ask

How do I change directories in Jupyter Notebook?

Change Jupyter Notebook startup folder (Windows) Copy the Jupyter Notebook launcher from the menu to the desktop. Right click on the new launcher and change the Target field, change %USERPROFILE% to the full path of the folder which will contain all the notebooks.

How do I change directory in Jupyter Lab?

How to change the working directory of Jupyter and Jupyter Lab on Windows environment. Open cmd (or Anaconda Prompt) and run jupyter notebook --generate-config . This writes a file to C:\Users\username\. jupyter\jupyter_notebook_config.py .

How do you make Jupyter notebooks run automatically?

How do I schedule a Jupyter Notebook to run? When your Jupyter notebook is ready for scheduling, open the Schedule runs option inside the Computation tab or access it from the Run menu in Datalore. Then choose the run interval (hourly, daily, weekly, monthly) and the time zone.


2 Answers

The commands were closing the prompt for some reason when executed in a .bat (they don't when typed). The fix was to type call before the commands.

F:
cd directoryname
call activate environmentname
call jupyter notebook
pause
like image 97
Jubei Avatar answered Sep 27 '22 22:09

Jubei


Create a simple batch file (jnote.bat):

@echo off
call jupyter notebook "%CD%"
pause

In the same folder create a shortcut to the batch file and rename it to jupyter-notebook.

Open the shortcut properties and change the icon to the jupyter.ico. You will find this in the .\Menu sub-folder in your Anaconda distribution. You should now have a shortcut with the) nice jupyter icon.

Copy the shortcut to all the folders that you use for your notebooks. Double-click the shortcut to open jupyter-notebook that folder.

like image 25
Steve Jones Avatar answered Sep 27 '22 23:09

Steve Jones