centos7安装jupyter notebook实现远程访问

版权声明:我们一同学习,望转载可以注明出处,谢谢 https://blog.csdn.net/weixin_43420032/article/details/89708796

centos7远程安装jupyter notebook实现远程没有python的机器也能运行python

jupyter代码补全详见【这篇文章】

想充分利用服务器的闲置资源,就萌发了这个念头,这样以后写测试练习直接浏览器输入服务器IP就可以了,手机都能操作

1、前提有ipython和jupyter

我是用的anaconda,已经集成这这两样了

2、生成配置文件

jupyter notebook --generate-config --allow-root

--allow-root是允许root运行此命令,不加此参数会提示错误,错误的解决建议就是加上这个参数

3、生成密码

3.1进入ipython
3.2from notebook.auth import passwd
3.3passwd()输入密码
3.4Out[2]: 'sha1:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'

4、修改第二步生成的配置文件

vi /root/.jupyter/jupyter_notebook_config.py

#修改为0.0.0.0可以任意远程IP访问
#c.NotebookApp.ip = 'localhost'
c.NotebookApp.ip = '0.0.0.0'

#代码存储的路径,记得前面的u'
#c.NotebookApp.notebook_dir = ''
c.NotebookApp.notebook_dir = u'/root/code'

#默认不打开浏览器,我用的远程登录,服务器没有桌面只需要运行服务即可,无需要此选项
#c.NotebookApp.open_browser = True
c.NotebookApp.open_browser = False

#这里填写的是上面在ipython中设置的密码后返回的sha1,我原本只写了sha1里面的内容,一直登录不上
#c.NotebookApp.password = ''
c.NotebookApp.password = u'sha1:xxxxxxxxxxxx:xxxxxxxxxxxxxxxxxxxxxxx'

#服务运行的端口,我这里就是默认端口
#c.NotebookApp.port = 8888
c.NotebookApp.port = 8888

5、启动jupyter

jupyter notebook --allow-root

6、远程浏览器访问

在其他电脑的浏览器输入http://ip:8888,提示输入密码,就输入在ipython中设置的密码即可

7、其他

操作过程中会出现报错,大概就是
ValueError: signal only works in main thread
网上查到了这篇文章
重新安装两个包就行了,还是包之间的版本冲突

pip install "pyzmq==17.0.0" "ipykernel==4.8.2"

猜你喜欢

转载自blog.csdn.net/weixin_43420032/article/details/89708796