xigang365

xigang365

Linux服务器上运行Jupyter并开启远程访问

安装 Anaconda#

  1. 通过清华开源站加速下载和安装
  2. 安装后,修改 conda 的安装源,用来加速

安装 Jupyter#

conda install jupyter

配置 Jupyter#

1. 生成密码#

jupyter-notebook password
# 输入2次密码,生成 ~/.jupyter/jupyter_notebook_config.json
cat ~/.jupyter/jupyter_notebook_config.json
# 计下密码,下一步需要使用

2. 生成配置文件#

jupyter-notebook --generate-config
# 生成的配置文件,默认保存在 ~/.jupyter/jupyter_notebook_config.py

3. 修改配置文件#

vim ~/.jupyter/jupyter_notebook_config.py
# 由于里面的内容已经全部注释,因此采用直接追加在末尾方式来实现
c.NotebookApp.ip = '*' # 监听所有IP
c.NotebookApp.open_browser = False # 默认不打开浏览器
c.NotebookApp.password = 'xxxx' # 使用第一步中的密码
c.NotebookApp.port = xxxx # 访问端口,请确保该端口未被占用,也可通过网络访问
c.NotebookApp.notebook_dir = 'xxxxx' # 设置 Jupyternotebook 打开的根目录

4. 运行#

# 测试运行
jupyter-notebook
# 后台运行
nohup jupyter-notebook
加载中...
此文章数据所有权由区块链加密技术和智能合约保障仅归创作者所有。