简体   繁体   中英

How to get Jupyter notebook to start under specific anaconda environment and under specific directory?

The default directory of Jupyter notebook is the C:\\Users\\User Name\\ I want to open several Jupyter notebooks in different folders at the same time (some of them in portable drives). additionally, I want to run Jupyter under specific Anaconda environment, with specific libraries and version of python.

I tried until I found the easiest and fastest solution for Windows which I will post in the answers below for the benefit of others.

I have provided the solution for windows, so I hope that others can add similar solutions for Mac and Linux.

Thanks

The easiest solution is to make a batch file ( *.bat ) with the following commands:

REM # A batch file to run Jupyter notebook  on the current folder 

REM # This is to switch to the current directory
setlocal
cd /d %~dp0

REM # If you need special Anaconda environment, replace the py3 name.
REM # If you want to run on the default environment, remove the line.
call activate py3

REM # It is important to add the 'call' 
call jupyter notebook

REM # The pause command is to keep the command window active.
pause

If you do not want to run a special Anaconda environment, remove the line call activate py3 . and if you want to activate different environment, replace the py3 by its name.

Finally, you have to save the commands above to a text file, rename it to LaunchJupyterHere.bat or any name of your choice, and place a copy of it in each folder you want to launch Jupyter in . once you want to launch Jupyter, double-click it, it will open a browser window pointing to the current directory, and under the specific environment.

Best regards

That may be the easiest windows solution; for me I use Anaconda; (1) activate the environment. (2) Open a terminal in that environment via 在此处输入图片说明 Then assuming I want the root to be my E: drive; just->

E:
jupyter notebook

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM