CentOS安装Anaconda、配置jupyter notebook、并打开ipynb文件
Anaconda的安装在她的官网上介绍的非常详细,按照官方指定步骤安装完事大吉。
Anaconda集成了jupyter notebook,所以在安装完成之后只需要配置就行了。
http://www.brianlv.com/20170401.html
https://www.cnblogs.com/jackzone/p/8387635.html
配置jupyter notebook的过程借鉴了以上两篇文章,但是因为我是在root用户下进行的安装所以路径有出入:
我们首先要生成一个jupyter的配置文件。
jupyter notebook --generate-config #生成的config file在/root/.jupyter/jupyter_notebook_config.py |
然后我们为了比较安全的访问服务器资源,我们需要设置登录密码和设置https来实现安全登录。如果有条件可以通过安全认证中心来发放秘钥和认证。首先打开ipython,生成sha1的密码,如下:
from notebook.auth import passwd passwd() #Enter password #output sha1:49acd1a985cc:beb1fb6859665bfa721e65e78fc511c41basdasa. |
然后生成一个自签名认证的key,如下:
openssl req -x509 -nodes -days 365 -newkey rsa:4096 -keyout jkey.key -out jcert.pem |
最后如下配置即可:
emacs /home/user/.jupyter/jupyter_notebook_config.py c.NotebookApp.password = 'sha1:<your-sha1-hash-value>' c.NotebookApp.port = 8888 c.NotebookApp.ip = '*' c.NotebookApp.open_browser = False c.NotebookApp.certfile = '/root/jcert.pem' c.NotebookApp.keyfile = '/root/jkey.key' #保存退出
添加环境变量
export PATH=/root/anaconda3/bin:$PATH source ~/.bash_profile
运行代码
jupyter notebook --ip=0.0.0.0 --no-browser --allow-root
在本地浏览器运行
打开浏览器输入http://xxx.xxx.xxx.xxx:8888/ (XXX为ip地址)
由于jupyter使用的8888作为默认端口,所以我需要把端口给开放并重启防火墙(或者直接关闭防火墙)。通过如下代码设置:
firewall-cmd --zone=public --add-port=8888/tcp --permanent systemctl restart firewalld.service |
到这里所有的安装和基本的设置都已经完成,可以在命令行输入:jupyter notebook以使用了。
安装配置好jupyter notebook之后,就可以打开ipynb文件了。
打开jupyter notebook,点击右上角的upload上传按钮,就可以上传你电脑上的.ipynb 文件,上传后可直接打开,显示如下界面:
转载于:https://my.oschina.net/ZhenyuanLiu/blog/1787526