Jupyter Notebook 远程访问配置
-
创建虚拟环境
conda create -n test python=3.9
-
进入虚拟环境
conda activate test
-
安装jupyter
pip install jupyter
-
设置登陆密码
ipython #进入交互模式 # jupyter-server 最近发布了新的版本升级 【新】 #jupyter notebook7 from jupyter_server.auth import passwd; passwd(algorithm='sha1') Enter password: Verify password: Out[2]: 'sha1:...' #此处需要记下来 【旧】 # jupyter notebook6 from notebook.auth import passwd passwd(algorithm='sha1') Enter password: Verify password: Out[2]: 'sha1:...' #此处需要记下来
-
生成配置文件
jupyter notebook --generate-config
自动在根目录下生成文件(~/.jupyter/jupyter_notebook_config.py)
-
修改配置文件
vim ~/.jupyter/jupyter_notebook_config.py 【新】 c.ServerApp.ip = '0.0.0.0' c.ServerApp.password = '' c.ServerApp.open_browser = False c.ServerApp.port = 8888 #若端口被占用可以视情况改 c.ServerApp.allow_remote_access = True 【旧】 c.NotebookApp.ip = '0.0.0.0' c.NotebookApp.password = '' c.NotebookApp.open_browser = False c.NotebookApp.port = 8888 c.NotebookApp.allow_remote_access = True
-
远程启动jupyter notebook
-
方法一
jupyter notebook --ip=0.0.0.0 --no-browser --allow-root
但这种会一直占着窗口,无法执行其他命令。
Ctrl + C
即可结束 -
方法二
nohup jupyter notebook --ip=0.0.0.0 --no-browser --allow-root> jupyter_notebook.log 2>&1 &
后台挂起运行,将运行日志重定向到当前目录下
jupyter_notebook.log
文件中。执行完之后会返回一行代码pid记住,结束进程的时候会用到。需要手动结束
kill -9 {对应pid}
-
Jupyter Notebook7汉化、自动补全
-
汉化
#pip安装方式 pip install jupyterlab-language-pack-zh-CN #conda安装方式 conda install -c conda-forge jupyterlab-language-pack-zh-CN
-
代码自动补全
设置➡设置编辑器➡代码补全➡启用自动补全