激活虚拟环境并以批处理文件方式启动 jupyter notebook

Activate virtual environement and start jupyter notebook all in batch file

我创建了以下批处理文件:jupyter_nn.bat。 内部文件我有:

cd "C:\My_favorite_path"
activate neuralnets
jupyter notebook

所以目标是激活conda虚拟环境并启动jupyter notebook。由于某种原因,这不起作用。 Window 立即关闭。如果我从 cmd 运行 这个批处理文件,它只执行 activate neulranets。我已经尝试过 pausepause>nul 以及其他巫毒舞。有什么建议么?这也是 Windows 7.

您需要在激活前添加CALL。由于 activate 是另一个批处理脚本,除非你 CALL 它,否则整个过程将退出。更多解释请看这里:How to run multiple .BAT files within a .BAT file

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

(您可能还需要 CALL Jupyter Notebook)