介绍
jupyter是IPython剥离出来成为一个语言无关的独立软件包。
jupyter已经支持50多种语言的内核,包括Lisp、R、F#、Perl、Ruby、Scala等。事实上即使IPython本身也是一个jupyter Python模块。提供 REPL(读取,求值,打印循环)交互式开发环境,类似于nrepl或SLIME。
依赖
- 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
创建虚拟环境
找一个你喜欢的目录创建虚拟环境,并激活
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 内容如下
numpy
matplotlib
scipy
pandas
scikit-learn
执行命令
python -m pip install -r requirements.txt -i http://pypi.douban.com/simple --trusted-host pypi.douban.com
最后我们来看看界面
生产环境
如果你没有sodu权限,怎么安装需要的一些python包
- 下载 virtualenv
tar xvfz virtualenv-15.1.0.tar.gz
cd virtualenv-15.1.0
python virtualenv.py --python=python包的位置 ~/venv
source activate