【问题标题】:Jupyter Notebook and VirtualBox VM sharing the same port (conflict) - how do I change the VM port?Jupyter Notebook 和 VirtualBox VM 共享同一个端口(冲突) - 如何更改 VM 端口?
【发布时间】:2021-05-26 07:51:43
【问题描述】:
我之前在我的 Mac 上设置了 Jupyter Notebook - 最近我在我的 Mac 上设置了一个 VirtualBox VM,我意识到当我的 VM 启动并运行时我无法运行我的 Jupyter Notebook(反之亦然)。
Jupyter notebook 是通过在我的 Mac 终端中键入“Jupyter Notebook”来调用的,它显示它在端口 8888 上运行。我了解 VirtualBox 默认设置有虚拟机在端口 8080 上运行。如何更改 VirtualBox VM 的端口(从 8080 到其他端口),以便我可以同时使用 VM 和 Jupyter Notebook?
【问题讨论】:
标签:
virtualbox
portforwarding
【解决方案1】:
我只知道如何配置 Jupyter Notebook,不知道 VirtualBox,因为我不会
使用它。
更改 Jupyter 端口的最简单方法是定义环境变量:
# Default port is 8888. It will automatically try the next 50 ports
# (8889, 8890, ...) if it finds something is already using that port
export JUPYTER_PORT=8888
把它放在你的.bashrc 或.zshrc,这取决于你使用什么shell。
更复杂的是生成和自定义 Jupyter 的配置:
jupyter notebook --generate-config
它会告诉你当前配置被转储到哪里。然后你可以设置
端口到该文件中您想要的任何内容:
## The port the notebook server will listen on (env: JUPYTER_PORT).
# Default: 8888
# c.NotebookApp.port = 8888