首先确定已经安装完成Anaconda,在安装过程中会安装jupyter notebook,下面只需配置jupyter notebook。

首先,生成jupyter notebook口令密钥

In [1]: from IPython.lib import passwd

In [2]: passwd()
Enter password: 123456
Verify password: 123456
Out[2]: 'sha1:105a8e883ae7:e13c10509ff419ffcd65978c3db1b5babcf7e8ba'

生成jupyter配置文件

jupyter notebook --generate-config

修改配置文件~/.jupyter/jupyter_notebook_config.py

c = get_config()
c.IPKernelApp.pylab = 'inline'

c.NotebookApp.ip = '*'
c.NotebookApp.open_browser = False
c.NotebookApp.password = u'sha1:105a8e883ae7:e13c10509ff419ffcd65978c3db1b5babcf7e8ba'
c.NotebookApp.port = 8888
c.NotebookApp.allow_origin='*'
c.NotebookApp.tornado_settings = {
    'headers': {
        'Content-Security-Policy': "frame-ancestors * 'self'"
    }
}

c.NotebookApp.notebook_dir='/opt/notebooks'

启动jupyter notebook

$ jupyter notebook

配置hdfs

jupyter notebook可以使用hdfs作为存储note的文件系统

c.NotebookApp.contents_manager_class='hdfscontents.hdfsmanager.HDFSContentsManager'
c.HDFSContentsManager.hdfs_namenode_host='10.110.18.217'
c.HDFSContentsManager.hdfs_namenode_port=8020
c.HDFSContentsManager.hdfs_user='hdfs'
c.HDFSContentsManager.root_dir='/notebooks'

安装多个kernel

在jupyter notebook中,python 2.7,python 3.5,或者是R等,都称为kernel

如果已经通过conda安装python 2.7和python 3.5两个python版本,可以直接添加相应的kernel

$ conda install -n py27 ipykernel

激活kernel(--user层面)

$ python -m ipykernel install --user

如果没有python 2.7或python 3.5的环境,可以通过conda直接创建环境和kernel

$ conda create -n py27 python=2.7 ipykernel

升级notebook

jupyter的升级

pip install -U notebook

或者是

conda update notebook

results matching ""

    No results matching ""