Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Activate virtual environement and start jupyter notebook all in batch file

I created the following batch file: jupyter_nn.bat. Inside file I have:

cd "C:\My_favorite_path"
activate neuralnets
jupyter notebook

So the goal is to activate conda virtual environment and start jupyter notebook. For some reason this does not work. Window immediately shuts down. If I run this batch file from cmd, it only executes activate neulranets. I already tried pause and pause>nul and other voodoo dances. Any suggestions? Also this is for Windows 7.

like image 815
user1700890 Avatar asked Feb 20 '17 19:02

user1700890


People also ask

How do I activate the Jupyter notebook environment?

Just run “jupyter notebook” command in the command prompt or Powershell and the jupyter environment will open up.

How do I start the Jupyter notebook in CMD?

To launch Jupyter Notebook App: Click on spotlight, type terminal to open a terminal window. Enter the startup folder by typing cd /some_folder_name . Type jupyter notebook to launch the Jupyter Notebook App The notebook interface will appear in a new browser window or tab.

How do I run a batch file in a Jupyter notebook?

Just double click the file to open jupyter notebook at the location. Note: File Location is the location of the notebook to open.


1 Answers

You need to add CALL before the activate. Since activate is another batch script, unless you CALL it, the whole process will exit. See here for more explanation: How to run multiple .BAT files within a .BAT file

cd "C:\My_favorite_path"
CALL activate neuralnets
jupyter notebook

(You might also need to CALL the Jupyter Notebook)

like image 99
darthbith Avatar answered Sep 24 '22 01:09

darthbith