jupter linux 无密码,如何在Ubuntu上配置jupyter notebook登录密码时遇到的密码无效问题...

文章包含3部分内容“

1、如何在linux远程服务器上配置jupyter notebook在本地显示

2、如何修改jupyter notebook的密码

3、将jupyter notebook挂后台(如何查看host)

进入正题

1、如何在linux远程服务器上配置jupyter notebook在本地显示:

在已经安装了anaconda的情况下,可以直接用pip install jupyter安装jupyter notebook

$ pip install jupyter

2、生成配置文件:

$ jupyter notebook --generate-config

3、生成密码(后续配置文件,登录时候需要)

$ python #进入python终端

>>> from IPython.lib import passwd

>>> passwd()

Enter password:

Verify password:

'sha1:1caed79badce:7e6d8261d400aec9a1cb60c8b6f5d14cb0d62d16' #记录下这个密码来,后面修改配置文件要用(如果出现此种情况Out[2]: 'argon2:$argon2id$v=19$m=10240,t=10,p=8$HtNcvOcGA697BNhe82s1fw$54JyGBgk4kDuLIo5LX3j0Q'  可以照直接在用户视图下键入命令jupyter notebook password,直接修改密码,然后run jupyter 进入登录界面直接 输入修改后的密码即可登录)

>>>exit()

4、修改默认配置文件

$vim ~/.jupyter/jupyter_notebook_config.py

修改配置如下,注意修改完要把注释去掉才能生效啊

c.NotebookApp.ip='your host ip'#10.10.10.10  #可以用hostname -i 或者hostname -I查看,或者host -i,host -I

c.NotebookApp.password = u'sha:ce...刚才复制的那个密文'

c.NotebookApp.open_browser = False

c.NotebookApp.port =8888 #随便指定一个端口,8899等等

c.IPKernelApp.pylab = 'inline'  #这个可能没有,找不到就不用管了

c.NotebookApp.notebook_dir = '/home/'   #设置jupyter启动后默认的文件夹

5、启动JupyterNotebook

$ jupyter notebook

6、远程访问

在本地浏览器拷贝http://yourhostip:8888就可以看到登录界面

输入密码可以愉快的使用啦,ip配置的一般都是内网,离开内网环境自然也就不能访问了

2、如何修改jupyter notebook的密码

1. initiaise the config file. (Only applied if the first time to run jupyter)

jupyter notebook --generate-config

2. on remote server

jupyter notebook password

这时生成的密码会在/.jupyter/jupyter_notebook_config.json里面,这样密码就重设成功了

3、将jupyter notebook挂后台(如何查看host)

上面的启动方式,会在当前目录生成一个日志文件,我忘了叫上面名字,总之随着jupyter notebook的运行,日志文件会越来越大,如果不是很重要,可以设置不记录日志,方法是将所有的输出都重定向到/dev/null 2>&1 &

此外,上面的启动方式是启动一个前台进程,如果ssh连接断开,jupyter notebook也就失效了,所以需要将jupyter notebook作为一个后台进程启动,在linux中是nohup命令。

1、# 不启动ssl,不记录日志输出,作为后台进程启动jupyter notebook

nohup jupyter notebook >/dev/null 2>&1 &

jupyter notebook作为后台进程启动后,如果想要停止它,可以先找到进程ID,然后kill。

# 查看进程

ps -ef | grep 'jupyter notebook'

# 输出如下,这里的21983即为进程id,

# hadoop    22136  21983  0 09:10 pts/1    00:00:00 grep jupyter notebook

# 杀死进程

kill -9 21983

# 此时浏览器无法再连接jupyter notebook了吧。

2、另外,一种比较简洁的小脚本,挂在后台,一直启动着jupyetr的方法:

jupyter_act.sh

host=  #用hostname -i 或者 hostname -I来查看

nohup jupyter notebook --ip $host  --no-browser --port 18888 1>nb.log 2>&1 & #设置host,及端口号等,将日志记录在nb.log里面

想要关掉挂在后台的jupyter notebook可以用: ps aux | grep jupyter 找到进程号,然后 kill -9 进程号即可

每次连接到远程服务器就不用再启动jupyter notebook了,直接用jupyter notebook list来查找你挂着的jupyter即可,很方便

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值