[英]How to get Jupyter notebook to start under specific anaconda environment and under specific directory?
Jupyter notebook 的默认目录是C:\\Users\\User Name\\
我想同时打开不同文件夹中的几个 Jupyter notebook(其中一些在便携式驱动器中)。 另外,我想在特定的 Anaconda 环境下运行 Jupyter,使用特定的库和 python 版本。
我一直在尝试,直到找到适用于 Windows 的最简单、最快速的解决方案,为了其他人的利益,我将在下面的答案中发布该解决方案。
我已经提供了windows的解决方案,所以希望其他人可以为Mac和Linux添加类似的解决方案。
谢谢
最简单的解决方案是使用以下命令制作批处理文件 ( *.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
如果您不想运行特殊的 Anaconda 环境,请删除call activate py3
。 如果要激活不同的环境,请将py3
替换为其名称。
最后,您必须将上述命令保存到一个文本文件中,将其重命名为LaunchJupyterHere.bat
或您选择的任何名称,并将其副本放在您想要在. 一旦你想启动 Jupyter,双击它,它会打开一个指向当前目录的浏览器窗口,并在特定环境下。
最好的问候
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.