之前都是使用docker中镜像自带的Jupyter,但是访问不到数据文件夹,就打算在服务器直接装一个
按照正常的方式
1. pip3 install jupyter
2. jupyter notebook --generate-config # 生成配置文件
3. 设置密码
python3 # 进入python编译环境
from notebook.auth import passwd
passwd()
Enter password:
Verify password:
Out: 'sha1:xxxxxxxx'
复制那一整串
4. vim ~/.jupyter/jupyter_notebook_config.py # 插入一下代码,不嫌烦可以把原来的注释取消
c.NotebookApp.ip='*' # 允许所有ip访问
c.NotebookApp.password = u'sha1:xxxxxxxxxxxxxx'
c.NotebookApp.open_browser = False
c.NotebookApp.port = 8888 # 访问端口
c.NotebookApp.notebook_dir = '/lab-pool/workspace/' # 指定目录
保存后
jupyter notebook # 启动服务
正常来说 此时从浏览器访问 服务器ip:8888端口,就会跳出来jupyter登录界面,输入密码即可
然而,出现了报错:socket.gaierror: [Errno -2] Name or service not known
查了一下,开启了端口还是一样
解决方法:把ip作为参数一起输入:
jupyter notebook --ip=192.168.1.220
nohup jupyter notebook --ip=192.168.1.220 & # Session断开也继续运行