一、远程连接
首先在服务器端安装jupyter notebook并通过配置文件进行相应参数的设置,然后使用本地主机的浏览器远程访问。
参考博客:https://my.oschina.net/u/4218785/blog/3142148
1.安装
conda activate abc pip install jupyter jupyter notebook --generate-config
备注:配置文件的所在路径一般为 ~/.jupyter/jupyter_notebook_config.py
注意:如果之前安装过,可能会提示你是否要重置配置文件,建议不要!(输入n)例如本机上重置可能会导致jupyter notebook无法正常在浏览器打开
2.生成密文
from IPython.lib import passwd passwd()
3.修改默认配置文件
vim ~/.jupyter/jupyter_notebook_config.py
文件内容如下:
c.NotebookApp.ip='*' c.NotebookApp.password = u'sha1:xxxxxxxxxxx(上一步生成的密文)' c.NotebookApp.port = 9999 c.NotebookApp.open_browser = False c.NotebookApp.allow_remote_access = True c.NotebookApp.allow_root = True c.NotebookApp.notebook_dir = '/home/user/myr'
4.运行
jupyter notebook
5.多用户连接配置
cp ~/.jupyter/jupyter_notebook_config.py ~/.jupyter/jpconfig.py vim ~/.jupyter/jpconfig.py jupyter notebook --config ~/.jupyter/jpconfig.py
参考博客:https://blog.csdn.net/qq_18506419/article/details/103915423
6.远程访问
在本地主机上打开浏览器,地址栏输入
服务器IP:端口号 10.10.10.10:9999
7.若配置完成后,在本地浏览器中无法访问服务器
在本地主机上的shell(Eg.使用MobaXterm新建shell)输入
ssh -p remote_port remote_user@remote_ip -L127.0.0.1:1234:127.0.0.1:服务器jupyter notebook的端口
在本地主机上打开浏览器,地址栏输入 127.0.0.1:1234 即可远程访问
参考博客:
https://www.jianshu.com/p/2fc5545901c7
https://blog.csdn.net/CZ505632696/article/details/79604446
二、切换虚拟环境
参考博客:https://blog.csdn.net/u014264373/article/details/86541767
conda activate abc conda install ipykernel python -m ipykernel install --user --name abc --display-name "Python3 abc"
打开Jupyter Notebook,顶部菜单栏选择Kernel–Change kernel–Python3 abc
如果报错ImportError: cannot import name ‘generator_to_async_generator’
pip uninstall -y ipython prompt_toolkit pip install ipython prompt_toolkit
参考博客:https://blog.csdn.net/u011331731/article/details/88310809
- 海报