[英]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). Jupyter notebook 的默认目录是C:\\Users\\User Name\\
我想同时打开不同文件夹中的几个 Jupyter notebook(其中一些在便携式驱动器中)。 additionally, I want to run Jupyter under specific Anaconda environment, with specific libraries and version of python.另外,我想在特定的 Anaconda 环境下运行 Jupyter,使用特定的库和 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.我一直在尝试,直到找到适用于 Windows 的最简单、最快速的解决方案,为了其他人的利益,我将在下面的答案中发布该解决方案。
I have provided the solution for windows, so I hope that others can add similar solutions for Mac and Linux.我已经提供了windows的解决方案,所以希望其他人可以为Mac和Linux添加类似的解决方案。
Thanks谢谢
The easiest solution is to make a batch file ( *.bat
) with the following commands:最简单的解决方案是使用以下命令制作批处理文件 ( *.bat
):
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
.如果您不想运行特殊的 Anaconda 环境,请删除call activate py3
。 and if you want to activate different environment, replace the py3
by its name.如果要激活不同的环境,请将py3
替换为其名称。
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 .最后,您必须将上述命令保存到一个文本文件中,将其重命名为LaunchJupyterHere.bat
或您选择的任何名称,并将其副本放在您想要在. 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.一旦你想启动 Jupyter,双击它,它会打开一个指向当前目录的浏览器窗口,并在特定环境下。
Best regards最好的问候
That may be the easiest windows solution;这可能是最简单的 Windows 解决方案; for me I use Anaconda;对我来说,我使用 Anaconda; (1) activate the environment. (1)激活环境。 (2) Open a terminal in that environment via (2) 通过在该环境中打开终端 Then assuming I want the root to be my E: drive;然后假设我希望根是我的 E: 驱动器; just->只是->
E:
jupyter notebook
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.