如何安装ipython notebook_IPython notebook安装指导
1.環(huán)境準備
yum -y install sqlite-devel #在安裝Python之前執(zhí)行,ipython notebook依賴sqlite執(zhí)行
pip install ipython
pip install notebook
pip install pysqlite #ipython notebook 依賴sqlite數(shù)據(jù)庫,必須安裝后才能使用
[錯誤處理]
如果安裝sqlite-devel后,執(zhí)行命令
ipython notebook
仍然出現(xiàn)下面的錯誤
"沒有名字為_sqlite3的模塊",一般來說需要重新編譯python環(huán)境然后使用下面的命令拷貝sqlite.so文件到系統(tǒng)目錄
cp /usr/local/src/Python-2.7.8/build/lib.linux-i686-2.7/_sqlite3.so /usr/local/lib/python2.7/sqlite3/
拷貝過去后,重新執(zhí)行
ipython notebook #此時應(yīng)該可以正常運行
2.配置啟動
2.1創(chuàng)建ipython notebook的登錄密碼
import IPython
IPython.lib.passwd('yourpassword')
2.2使用supervisor進行ipython notebook的管理
#添加程序到supervisor
[program:notebook]
command = ipython notebook --notebook-dir=/R3/notebook/notebook/ --ip=ip_addr --no-mathjax --no-browser --NotebookApp.password=sha1:5
2de8d6f2ea6:90387094a062f493e7eea3df503c28ab3c3b8bf1
directory=/R3/notebook
stopsignal=QUIT
autostart=true
autorestart=true
startsecs=10
startretries=36
stdout_logfile=/R3/logs/ipython_check.log
stdout_logfile_backups=10
stdout_logfile_maxbytes=10MB
stderr_logfile=/R3/logs/ipython_check_err.log
stderr_logfile_maxbytes=10MB
stderr_logfile_backups=10
loglevel=info
[command說明]
--notebook-dir 指定notebook的工作目錄
--ip=169.24.2.82 指定notebook的服務(wù)器IP地址
--no-mathjax 禁止聯(lián)網(wǎng)下載math的js
--no-browser 禁止啟動時打開瀏覽器
--NotebookApp.password 指定用戶密碼(上述中創(chuàng)建的密碼)
關(guān)于supervisor的安裝配置及管理可參見官方站點
2.3設(shè)置開啟以普通用戶的方式執(zhí)行supervisord程序
將下面的命令添加到/etc/rc.local文件中
su - george -c 'supervisord -c /etc/supervisor.conf'
每次啟動后會自動啟動supervisord進程,由該進程服務(wù)對ipython notebook進程進行管理
2.4檢查是否正常啟動
netstat -tunl|grep 8888檢查服務(wù)器是否在8888端口進行監(jiān)聽
檢查防火墻是否授權(quán)8888端口對外提供服務(wù)
瀏覽器中輸入 http://ip:8888/會自動跳轉(zhuǎn)到要求輸入密碼
**建議使用Firefox瀏覽器進行訪問**
3.配置Nginx使其支持notebook的反向代理
location / {
proxy_pass http://ip:8888;
proxy_set_header Host $http_host;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_read_timeout 86400;
}
**本質(zhì)上notebook的通訊機制是使用websocket,在nginx的配置上要讓其支持websocket才行
proxy_set_header Connection "$Upgrade"表示其支持websocket
**
總結(jié)
以上是生活随笔為你收集整理的如何安装ipython notebook_IPython notebook安装指导的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
 
                            
                        - 上一篇: sql知识点小汇总(知识点汇总复习)
- 下一篇: mysql语句中的冒号是什么意思?(四个
