参考博文:【Pycharm】Pycharm+jupyter远程配置教程、及解决pycharm显示variables are unavailable集群报“No session ID specified“问题_小丫么小阿豪的博客-优快云博客
在服务器上安装jupyter
conda install jupyter
pip install jupyer
两个选一个都可以。
生成jupyter配置文件jupyter_notebook_config.py
jupyter notebook --generate-config
(生成的配置文件的位置在:/home/xxx/.jupyter/jupyter_notebook_config.py
xxx是你的用户名)
生成密码
jupyter notebook password
Enter password: xxxx
Verify password: xxxx
[NotebookPasswordApp] Wrote hashed password to /home/xxx/.jupyter/jupyter_notebook_config.json
修改配置文件
vim /home/xxx/.jupyter/jupyter_notebook_config.py
我是直接Xftp更改
vim中跳转到文件末尾:
在vim打开文件后按 shift+g 跳转到文件末尾。也可以在开头编辑,这里列出只是方便新手了解直接跳到文件末尾的方法,万一哪天用上了呢hhhhhhh。(config文件打开里面应该全是注释,相信自己,你的config文件没问题,不要慌…)
# ip 设置为 *
c.NotebookApp.ip = '*'
# hash密码,前面的u不可以省略,后面的hash密码就是在.json文件中双引号里的内容
c.NotebookApp.password = u'<your hashed password here>'
# 浏览器设置不打开
c.NotebookApp.open_browser = False
# 设置一个固定端口,设置一个没有占用就好
c.NotebookApp.port = 8888
# 这个可加可不加,亲测似乎不加也没什么问题
c.NotebookApp.allow_remote_access = True
这样以后可以直接通过浏览器访问http://ip:port?token=
在pycharm上配置jupyter
- 在server上启动jupyter,具体参考上一步
- 新建一个jupyter notebook文件
- 输入服务器地址:
http://ip:port?token=xxx
(xxx是你的明文密码,不是hash密码)
更改notebook地址
import os
os.chdir('/home/gfq/code/privacy/NRGNN')
from models.GCN import GCN
from models.NRGNN import NRGNN
这样才能把默认路径移动一下。
nohup jupyter notebook >jupyter.log 2>&1 &
可以通过这个将notebook挂载到后端