Jupyter Notebook Mammuals

来源:互联网 发布:linux nginx 域名绑定 编辑:程序博客网 时间:2024/06/13 01:36

Coding Interface: Jupyter Notebook

​ Official website: http://jupyter.org/

​ Using Anaconda installing Jupyter Notebook on Windows computer:

Anaconda:

Installation:

  1. Download Anaconda, official website: https://www.continuum.io/downloads or mirror from Tsing Hua university open software station: https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/
  2. Anaconda3 contains python 3.6, while Anaconda2 contains python 2.7.
  3. Please don’t use the install path with ’ ‘, such as “D:\Program Files\Anaconda3”, it will cause some error in future!
  4. Please choose “Add Anaconda to my PATH environment variable”.

Changing package source:

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/conda config --set show_channel_urls yes

Environment Management:

conda create -n python27 python=2.7         # install a new environmentconda info -e                               # Checking current environmentsconda remove -n python27 --all              # remove an environmentactivate python27                           # activate an environment on Windowssource activate python27                    # activate an environment on Linux/Macdeactivate python27                         # deactivate an environment on Windowssource deactivate python                    # deactivate an environment on Linux/Macconda install -n python27 lxml              # install a package for a paticulate environmentconda remove -n python27 lxml               # uninstall a package from a paticulate environment

Jupyter notebook

Installation:

  1. Anaconda3-4.4.0 has already install Jupyter Notebook for its default python environment python3.6

  2. If you want to install Jupyter Notebook for an already existed environment, there has two ways:

    • Install Anaconda scientific Computing packages for the environment, it will default install Jupyter Notebook
    conda install -n python27 anaconda
    • Install Jupyter Notebook noly:
    conda install -n python27 ipykernel
  3. If you want to create a new environment which has Jupyter Notebook:

    conda create -n python27 python=2.7 ipykernel

    In the same way, if you want the new created environment has more package, please add package names after python=x.x.

  4. Add python2.7 kernel into Jupyter Notebook

    activate python27python -m ipykernel install --name=Python2.7python -m ipykernel install --name=Python2.7 --user    # add kernel option only to current userjupyter kernelspec list                               # list current kernels added in notebookjupyter kernelspec remove name_of_a_specific_kernel

How to start Notebook?

  1. Start Notebook local server

    jupyter nootbook        # start with open a browserjupyter nootbook --no-browser       # start without open a browser
  2. Help Documents:

    jupyter nootbook --help
  3. Changing default local host port. The notebook server default starts on port 8888. If port 8888 is unavailable or in use, the notebook server searches the next available port.

    jupyter nootbook --port 9999     # you can change the port number as your 
  4. Changing Default Working Space:

    jupyter notebook --generate-config# create configure file, usually at C:/users/curent_user/.jupyter/jupyter_notebook_config.py

    If system show that you have already has a configure file, don’t overwrite it!

    Find this “jupyter_notebook_config.py” configure file, and changing the line:

    # The directory to use for notebooks and kernels.# c.NotebookApp.notebook_dir = u''

    As:

    # The directory to use for notebooks and kernels.c.NotebookApp.notebook_dir = u'D:\Your\Jupypter\Workspace\Directory'

    Similarly, you can also create ipython configure file:

    ipython notebook --generate-config

Notebook Extension

There are many notebook extension package, you may need it:

conda install -c conda-forge jupyter_contrib_nbextensions

After install “jupyter_contrib_nbextensions”, you will find a new Label “Nbextension” on Notebook Home page.

这里写图片描述

You can choose your prefer extensions under this label.

Conda Extension on Jupyter Notebook:

Introduction pages: https://docs.continuum.io/anaconda/user-guide/tasks/use-jupyter-notebook-extensions

conda install nb_conda

This package will add a new Label “Conda” on Jupyter Notebook Home page. You can manage your environment and packages under this Laber.

You can edit your environment, notebook kernels and packages in this interface.

这里写图片描述

If you add “nb_conda ” package, it will add kernel choses in “new notebook”, and you can change the default kernel in the “Conda” interface.

这里写图片描述

It will also add “presentation” and “cloud” on each notebook’s edition pages.

这里写图片描述

Notice that, nb_cloud & nb_presentation only support on Windows 10. At lest it doesn’t work on my computer!