Ubuntu 搭建jupyter web server,Jupyter notebook远程访问 JupyterLab

Ubuntu 搭建jupyter web server,Jupyter notebook远程访问

  1. ubuntu20.04安装anaconda3

  2. 创建虚拟环境,安装jupyter notebook

conda create -n jupter python=3.7
Proceed ([y]/n)? 输入y,回车
conda activate jupter
conda install jupyter notebook
Proceed ([y]/n)? 输入y,回车
  1. Jupyter notebook 配置
1. 生成配置文件
jupyter notebook --generate-config
Writing default config to: /home/chengjialin/.jupyter/jupyter_notebook_config.py (配置文件所在路径)
2. 创建密码
使用python中的passwd()创建密码,终端输入ipython打开ipython并输入:
In [1]: from notebook.auth import passwd
In [2]: passwd()
Enter password: ******
Verify password: ******
Out [2]: 'sha1:...'
复制Out [2] 显示的密码('sha1:...' 包括引号)。
  1. 修改jupyter notebook的配置文件
vim ~/.jupyter/jupyter_notebook_config.py
在该文件中做如下修改或直接在文件尾端添加:
c.NotebookApp.allow_remote_access = True #允许远程连接
c.NotebookApp.ip='*' # 设置所有ip皆可访问
c.NotebookApp.password = u'sha:..' #之前复制的密码
c.NotebookApp.open_browser = False # 禁止自动打开浏览器
c.NotebookApp.port =8888 #任意指定一个端口
  1. 设置notebook中文显示
查看环境变量:
(py38) ubuntu@VM-0-3-ubuntu:~$ env
可以看到:LANGUAGE=en_US.utf8:
查看是否安装有中文语言包:
(py38) ubuntu@VM-0-3-ubuntu:~$ locale -a
C
C.UTF-8
en_US.utf8
POSIX
没有就安装:
(py38) ubuntu@VM-0-3-ubuntu:~$ sudo apt-get install language-pack-zh-hans
Do you want to continue? [Y/n] 输入y,回车
修改locale文件配置
(py38) ubuntu@VM-0-3-ubuntu:~$sudo vim /etc/default/locale
按i键,删除当前内容,再输入以下内容
  1. 启动jupyter notebook
重启shell,再次激活jupter环境,运行jupyter notebook
终端输入:
jupyter notebook
或使用nohup后台运行 jupyter notebook:
nohup jupyter notebook >~/jupyter.log 2>&1 &
  1. 远程访问jupyter notebook
本地浏览器输入http://(服务器地址):(配置文件中设定的端口); 假设服务器地址为192.168.1.129,配置的端口为8888,这里的浏览器输入地址应为http://192.168.1.129:8888; 即可访问jupyter notebook。

参考:
https://cloud.tencent.com/developer/article/1918314
https://www.zhihu.com/tardis/zm/art/87403131?source_id=1003

https://www.jiguiquan.com/?p=4078

https://zhuanlan.zhihu.com/p/38612108
https://blog.csdn.net/m0_64087341/article/details/133562004
https://www.zhihu.com/tardis/zm/art/87403131?source_id=1003

posted @   michaelchengjl  阅读(618)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
历史上的今天:
2021-07-13 Jenkins详细教程
点击右上角即可分享
微信分享提示