Mac远程访问ubuntu jupyter notebook

  • 安装jupyter, ipython
  • 远程访问

安装jupyter, ipyhton

>>> sudo python3 -m pip install ipython==6.5.0
>>> sudo python3 -m pip install jupyter

最新的ipython==7.2.0和jupyter的prompt-tookit版本冲突,因而安装ipython==6.5.0。
最后jupyter安装在了~/.local/bin/路径下。

>>> jupyter notebook
jupyter: command not found

需要在.bashrc中设置环境变量

>>> vim ~/.bashrc

在文件最后加上

export PATH=$PATH:~/.local/bin
>>> source .bashrc

远程访问

jupyter notebook默认只能通过本机的localhost访问服务器,我们可以通过修改配置实现远程访问。

  • 生成配置文件
>>> jupyter notebook --generate-config

如果提示权限不够可先修改权限

>>> sudo chmod 777 .jupyter/
>>> jupyter notebook --generate-config
  • 修改配置文件
>>> vim .jupyter/jupyter_notebook_config.py

修改其中两个参数

c.NotebookApp.allow_origin = '*' #允许从任何来源访问服务器
c.NotebookApp.ip = '0.0.0.0' #监听所有IP地址
>>> jupyter notebook --no-browser
记下生成的token

在Mac上打开浏览器,输入http://xx.xx.xx.xx:8888
输入生成的token即可。

猜你喜欢

转载自blog.csdn.net/MacwinWin/article/details/87029996