安裝使用jupyter

介紹

jupyter是IPython剝離出來成爲一個語言無關的獨立軟件包。node

jupyter已經支持50多種語言的內核,包括Lisp、R、F#、Perl、Ruby、Scala等。事實上即便IPython自己也是一個jupyter Python模塊。提供 REPL(讀取,求值,打印循環)交互式開發環境,相似於nrepl或SLIME。python

依賴

  • python
  • pip
  • virtualenv: python資源隔離工具包,用於建立隔離的專屬python環境

安裝

pip

wget --no-check-certificate https://pypi.python.org/packages/source/s/setuptools/setuptools-12.0.3.tar.gz#md5=f07e4b0f4c1c9368fcd980d888b29a65
tar -zxvf setuptools-12.0.3.tar.gz
cd setuptools-12.0.3
python setup.py install

wget --no-check-certificate https://github.com/pypa/pip/archive/1.5.5.tar.gz
tar zvxf 1.5.5.tar.gz  
cd pip-1.5.5/
python setup.py install

virtualenv

pip install virtualenv

建立虛擬環境

找一個你喜歡的目錄建立虛擬環境,並激活git

mkdir jupyter
cd jupyter
virtualenv venv --python=python2.7
source ./venv/activate

退出虛擬環境
source ./venv/deactivate

安裝,配置,啓動 jupyter notebook

pip install jupyter
jupyter notebook --generate-config # 生成配置文件

輸入ipython命令,依次敲入以下代碼,並輸入網站訪問時須要填寫的密碼

In [1]: from notebook.auth import passwd
In [2]: passwd()
Enter password:
Verify password:
Out[2]: 'sha1:67c9e60bb8b6:9ffede0825894254b2e042ea597d771089e11aed'
openssl req -x509 -nodes -days 365 -newkey rsa:1024 -keyout mykey.key -out mycert.pe # 產生祕鑰

修改配置文件

vim ~/.jupyter/jupyter_notebook_config.py
# Set options for certfile, ip, password, and toggle off browser auto-opening
c.NotebookApp.certfile = u'/absolute/path/to/your/certificate/mycert.pem'
c.NotebookApp.keyfile = u'/absolute/path/to/your/certificate/mykey.key'
# Set ip to '*' to bind on all interfaces (ips) for the public server
c.NotebookApp.ip = '*'
c.NotebookApp.password = u'sha1:bcd259ccf...<your hashed password here>'
c.NotebookApp.open_browser = False

# It is a good idea to set a known, fixed port for server access
c.NotebookApp.port = 9999

啓動服務

jupyter notebook # 啓動服務

數據分析和數據挖掘經常使用包

建立文件 requirements.txt 內容以下github

numpy
matplotlib
scipy
pandas
scikit-learn

執行命令shell

python -m pip install -r requirements.txt -i http://pypi.douban.com/simple --trusted-host pypi.douban.com

最後咱們來看看界面

生產環境

若是你沒有sodu權限,怎麼安裝須要的一些python包vim

  • 下載 virtualenv

tar xvfz virtualenv-15.1.0.tar.gz
cd virtualenv-15.1.0
python virtualenv.py  --python=python包的位置  ~/venv
source activate
相關文章
相關標籤/搜索