Jupyter Notebook的官方网站强烈建议的安装方式是通过Anaconda安装。

JUPYTER官网:
https://jupyter.org

JUPYTER官方安装页:
https://jupyter.org/install.html

Anaconda的介质下载页面:
https://www.anaconda.com/download/

将下载好的介质上传服务器:

[root@codebase ~]# mkdir /software
[root@codebase ~]# 
[root@codebase ~]# ls /software
[root@codebase ~]# 
[root@codebase ~]# ls -ltr /software/
total 668204
-rw-r--r-- 1 root root 684237703 Jan 10 00:34 Anaconda3-2018.12-Linux-x86_64.sh
[root@codebase ~]# 
[root@codebase ~]# du -sh /software/*
653M    /software/Anaconda3-2018.12-Linux-x86_64.sh
[root@codebase ~]# 

执行安装:

[root@codebase ~]# df -h
Filesystem               Size  Used Avail Use% Mounted on
/dev/mapper/centos-root   67G  5.0G   62G   8% /
devtmpfs                 7.9G     0  7.9G   0% /dev
tmpfs                    7.9G     0  7.9G   0% /dev/shm
tmpfs                    7.9G  9.7M  7.9G   1% /run
tmpfs                    7.9G     0  7.9G   0% /sys/fs/cgroup
/dev/sda1               1014M  157M  858M  16% /boot
tmpfs                    1.6G   36K  1.6G   1% /run/user/0
/dev/sr0                 4.2G  4.2G     0 100% /run/media/root/CentOS 7 x86_64
[root@codebase ~]# 
[root@codebase ~]# sh /software/Anaconda3-2018.12-Linux-x86_64.sh 

Welcome to Anaconda3 2018.12

In order to continue the installation process, please review the license
agreement.
Please, press ENTER to continue
>>>    回车

(过多的输出。)

d by Intel(TM) as ECCN 5D992b with no license required for export to non-embargoed countries and Microsoft's Visual Studio Code softwar
e is classified by Microsoft as ECCN 5D992.c with no license required for export to non-embargoed countries.

The following packages are included in this distribution that relate to cryptography:

openssl
    The OpenSSL Project is a collaborative effort to develop a robust, commercial-grade, full-featured, and Open Source toolkit impleme
nting the Transport Layer Security (TLS) and Secure Sockets Layer (SSL) protocols as well as a full-strength general purpose cryptograp
hy library.

pycrypto
    A collection of both secure hash functions (such as SHA256 and RIPEMD160), and various encryption algorithms (AES, DES, RSA, ElGama
l, etc.).

pyopenssl
    A thin Python wrapper around (a subset of) the OpenSSL library.

kerberos (krb5, non-Windows platforms)
    A network authentication protocol designed to provide strong authentication for client/server applications by using secret-key cryp
tography.

cryptography
    A Python library which exposes cryptographic recipes and primitives.


Do you accept the license terms? [yes|no]
[no] >>> yes

Anaconda3 will now be installed into this location:
/root/anaconda3

  - Press ENTER to confirm the location
  - Press CTRL-C to abort the installation
  - Or specify a different location below


[/root/anaconda3] >>> /opt/anaconda3   
PREFIX=/opt/anaconda3
installing: python-3.7.1-h0371630_7 ...
Python 3.7.1
installing: blas-1.0-mkl ...
installing: ca-certificates-2018.03.07-0 ...
installing: conda-env-2.6.0-1 ...
installing: intel-openmp-2019.1-144 ...
installing: libgcc-ng-8.2.0-hdf63c60_1 ...
installing: libgfortran-ng-7.3.0-hdf63c60_0 ...
installing: libstdcxx-ng-8.2.0-hdf63c60_1 ...
installing: bzip2-1.0.6-h14c3975_5 ...
installing: expat-2.2.6-he6710b0_0 ...
installing: fribidi-1.0.5-h7b6447c_0 ...
installing: gmp-6.1.2-h6c8ec71_1 ...
installing: graphite2-1.3.12-h23475e2_2 ...
installing: icu-58.2-h9c2bf20_1 ...

(过多的输出。)

installing: widgetsnbextension-3.4.2-py37_0 ...
installing: ipywidgets-7.4.2-py37_0 ...
installing: jupyterlab-0.35.3-py37_0 ...
installing: spyder-3.3.2-py37_0 ...
installing: _ipyw_jlab_nb_ext_conf-0.1.0-py37_0 ...
installing: jupyter-1.0.0-py37_7 ...
installing: anaconda-2018.12-py37_0 ...
installing: conda-4.5.12-py37_0 ...
installing: conda-build-3.17.6-py37_0 ...
installation finished.
Do you wish the installer to initialize Anaconda3
in your /root/.bashrc ? [yes|no]
[no] >>> yes

Initializing Anaconda3 in /root/.bashrc
A backup will be made to: /root/.bashrc-anaconda3.bak


For this change to become active, you have to open a new terminal.

Thank you for installing Anaconda3!

===========================================================================

Anaconda is partnered with Microsoft! Microsoft VSCode is a streamlined
code editor with support for development operations like debugging, task
running and version control.

To install Visual Studio Code, you will need:
  - Administrator Privileges
  - Internet connectivity

Visual Studio Code License: https://code.visualstudio.com/license

Do you wish to proceed with the installation of Microsoft VSCode? [yes|no]
>>> yes
Proceeding with installation of Microsoft VSCode
Checking Internet connectivity ...
Installing Visual Studio Code ...
Loaded plugins: fastestmirror, langpacks

(过多的输出。)

xorg-x11-drv-intel.x86_64                                               2.99.917-28.20180530.el7                              base     
xorg-x11-drv-nouveau.x86_64                                             1:1.0.15-1.el7                                        base     
xorg-x11-drv-qxl.x86_64                                                 0.1.5-4.el7.1                                         base     
xorg-x11-drv-synaptics.x86_64                                           1.9.0-2.el7                                           base     
xorg-x11-drv-v4l.x86_64                                                 0.2.0-49.el7                                          base     
xorg-x11-drv-vesa.x86_64                                                2.4.0-1.el7                                           base     
xorg-x11-drv-vmmouse.x86_64                                             13.1.0-1.el7.1                                        base     
xorg-x11-drv-vmware.x86_64                                              13.2.1-1.el7.1                                        base     
xorg-x11-drv-void.x86_64                                                1.4.1-2.el7.1                                         base     
xorg-x11-drv-wacom.x86_64                                               0.36.1-1.el7                                          base     
xorg-x11-font-utils.x86_64                                              1:7.5-21.el7                                          base     
xorg-x11-proto-devel.noarch                                             2018.4-1.el7                                          base     
xorg-x11-server-Xorg.x86_64                                             1.20.1-5.1.el7                                        updates  
xorg-x11-server-common.x86_64                                           1.20.1-5.1.el7                                        updates  
xorg-x11-utils.x86_64                                                   7.5-23.el7                                            base     
xorg-x11-xkb-utils.x86_64                                               7.7-14.el7                                            base     
yelp.x86_64                                                             2:3.28.1-1.el7                                        base     
yelp-libs.x86_64                                                        2:3.28.1-1.el7                                        base     
yelp-xsl.noarch                                                         3.28.0-1.el7                                          base     
yum.noarch                                                              3.4.3-161.el7.centos                                  base     
yum-plugin-fastestmirror.noarch                                         1.1.31-50.el7                                         base     
yum-utils.noarch                                                        1.1.31-50.el7                                         base     
zenity.x86_64                                                           3.28.1-1.el7                                          base     
zlib.x86_64                                                             1.2.7-18.el7                                          base     
Obsoleting Packages
gnome-dictionary.x86_64                                                 3.26.1-2.el7                                          base     
    gnome-dictionary-libs.x86_64                                        3.20.0-1.el7                                          @anaconda
gnome-shell.x86_64                                                      3.28.3-6.el7                                          base     
    python2-caribou.noarch                                              0.4.21-1.el7                                          @anaconda
gnome-shell.x86_64                                                      3.28.3-6.el7                                          base     
    caribou-gtk3-module.x86_64                                          0.4.21-1.el7                                          @anaconda
gnome-shell.x86_64                                                      3.28.3-6.el7                                          base     
    caribou-gtk2-module.x86_64                                          0.4.21-1.el7                                          @anaconda
gnome-shell.x86_64                                                      3.28.3-6.el7                                          base     
    caribou.x86_64                                                      0.4.21-1.el7                                          @anaconda
gnome-tweak-tool.noarch                                                 3.28.1-2.el7                                          base     
    gnome-tweak-tool.noarch                                             3.22.0-1.el7                                          @anaconda
grub2.x86_64                                                            1:2.02-0.76.el7.centos                                base     
    grub2.x86_64                                                        1:2.02-0.65.el7.centos.2                              @anaconda
grub2-tools.x86_64                                                      1:2.02-0.76.el7.centos                                base     
    grub2-tools.x86_64                                                  1:2.02-0.65.el7.centos.2                              @anaconda
grub2-tools-extra.x86_64                                                1:2.02-0.76.el7.centos                                base     
    grub2-tools.x86_64                                                  1:2.02-0.65.el7.centos.2                              @anaconda
grub2-tools-minimal.x86_64                                              1:2.02-0.76.el7.centos                                base     
    grub2-tools.x86_64                                                  1:2.02-0.65.el7.centos.2                              @anaconda
libwayland-egl.x86_64                                                   1.15.0-1.el7                                          base     
    mesa-libwayland-egl.x86_64                                          17.2.3-8.20171019.el7                                 @anaconda
python2-pyatspi.noarch                                                  2.26.0-3.el7                                          base     
    pyatspi.noarch                                                      2.20.3-1.el7                                          @anaconda
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.163.com
 * extras: mirrors.163.com
 * updates: mirrors.163.com
Resolving Dependencies
--> Running transaction check
---> Package code.x86_64 0:1.30.2-1546901769.el7 will be installed
--> Processing Dependency: libXss.so.1()(64bit) for package: code-1.30.2-1546901769.el7.x86_64
--> Running transaction check
---> Package libXScrnSaver.x86_64 0:1.2.2-6.1.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=======================================================================================================================================
 Package                           Arch                       Version                                   Repository                Size
=======================================================================================================================================
Installing:
 code                              x86_64                     1.30.2-1546901769.el7                     code                      63 M
Installing for dependencies:
 libXScrnSaver                     x86_64                     1.2.2-6.1.el7                             base                      24 k

Transaction Summary
=======================================================================================================================================
Install  1 Package (+1 Dependent package)

Total download size: 63 M
Installed size: 184 M
Downloading packages:
warning: /var/cache/yum/x86_64/7/base/packages/libXScrnSaver-1.2.2-6.1.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Public key for libXScrnSaver-1.2.2-6.1.el7.x86_64.rpm is not installed
(1/2): libXScrnSaver-1.2.2-6.1.el7.x86_64.rpm                                                                   |  24 kB  00:00:00     
(2/2): code-1.30.2-1546901769.el7.x86_64.rpm                                                                    |  63 MB  00:00:13     
---------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                  4.6 MB/s |  63 MB  00:00:13     
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Importing GPG key 0xF4A80EB5:
 Userid     : "CentOS-7 Key (CentOS 7 Official Signing Key) "
 Fingerprint: 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
 Package    : centos-release-7-5.1804.el7.centos.x86_64 (@anaconda)
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : libXScrnSaver-1.2.2-6.1.el7.x86_64                                                                                  1/2 
  Installing : code-1.30.2-1546901769.el7.x86_64                                                                                   2/2 
  Verifying  : code-1.30.2-1546901769.el7.x86_64                                                                                   1/2 
  Verifying  : libXScrnSaver-1.2.2-6.1.el7.x86_64                                                                                  2/2 

Installed:
  code.x86_64 0:1.30.2-1546901769.el7                                                                                                  

Dependency Installed:
  libXScrnSaver.x86_64 0:1.2.2-6.1.el7                                                                                                 

Complete!
Updating VSCode Config ...
Installing Extensions ...
Found 'ms-python.anaconda-extension-pack' in the marketplace.
Installing...
Extension 'ms-python.anaconda-extension-pack' v1.0.1 was successfully installed!
VSCode successfully installed in /usr/share/code !

[root@codebase ~]# 

这样,ANACONDA,就安装好了。

来看看安装后的系统:

[root@codebase ~]# whereis python
python: /usr/bin/python /usr/bin/python2.7 /usr/lib/python2.7 /usr/lib64/python2.7 /etc/python /usr/include/python2.7 /opt/anaconda3/bin/python /opt/anaconda3/bin/python3.7-config /opt/anaconda3/bin/python3.7m /opt/anaconda3/bin/python3.7 /opt/anaconda3/bin/python3.7m-config /usr/share/man/man1/python.1.gz
[root@codebase ~]# 
[root@codebase ~]# ls -ltr /usr/bin | grep python
-rwxr-xr-x. 1 root root       7216 Apr 11  2018 python2.7
-rwxr-xr-x. 1 root root      11312 Apr 27  2018 abrt-action-analyze-python
lrwxrwxrwx. 1 root root          9 Jan 10 12:59 python2 -> python2.7
lrwxrwxrwx. 1 root root          7 Jan 10 12:59 python -> python2
[root@codebase ~]# 
[root@codebase ~]# /opt/anaconda3/bin/python -V
Python 3.7.1
[root@codebase ~]# 
[root@codebase ~]# /opt/anaconda3/bin/python
Python 3.7.1 (default, Dec 14 2018, 19:28:38) 
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> quit
Use quit() or Ctrl-D (i.e. EOF) to exit
>>> quit()
[root@codebase ~]# 

可以看到,安装了一个PYTHON3

还有两个命令:

[root@codebase ~]# whereis anaconda
anaconda: /usr/sbin/anaconda /usr/libexec/anaconda /usr/share/anaconda /opt/anaconda3/bin/anaconda
[root@codebase ~]# 
[root@codebase ~]# whereis jupyter
jupyter: /opt/anaconda3/bin/jupyter
[root@codebase ~]# 

配置环境变量:

[root@codebase ~]# whereis jupyter
jupyter: /opt/anaconda3/bin/jupyter
[root@codebase ~]# 
[root@codebase ~]# env | grep jupyter
[root@codebase ~]# 
[root@codebase ~]# cat .bashrc
# .bashrc

# User specific aliases and functions

alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'

# Source global definitions
if [ -f /etc/bashrc ]; then
        . /etc/bashrc
fi
# added by Anaconda3 2018.12 installer
# >>> conda init >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$(CONDA_REPORT_ERRORS=false '/opt/anaconda3/bin/conda' shell.bash hook 2> /dev/null)"
if [ $? -eq 0 ]; then
    \eval "$__conda_setup"
else
    if [ -f "/opt/anaconda3/etc/profile.d/conda.sh" ]; then
        . "/opt/anaconda3/etc/profile.d/conda.sh"
        CONDA_CHANGEPS1=false conda activate base
    else
        \export PATH="/opt/anaconda3/bin:$PATH"
    fi
fi
unset __conda_setup
# <<< conda init <<<
[root@codebase ~]# 

[root@codebase ~]# vi ~/.bash_profile
[root@codebase ~]# 
[root@codebase ~]# cat ~/.bash_profile 
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs

PATH=/opt/anaconda3/bin/jupyter:$PATH:$HOME/bin

export PATH

# added by Anaconda3 2018.12 installer
# >>> conda init >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$(CONDA_REPORT_ERRORS=false '/opt/anaconda3/bin/conda' shell.bash hook 2> /dev/null)"
if [ $? -eq 0 ]; then
    \eval "$__conda_setup"
else
    if [ -f "/opt/anaconda3/etc/profile.d/conda.sh" ]; then
        . "/opt/anaconda3/etc/profile.d/conda.sh"
        CONDA_CHANGEPS1=false conda activate base
    else
        \export PATH="/opt/anaconda3/bin:$PATH"
    fi
fi
unset __conda_setup
# <<< conda init <<<
[root@codebase ~]# 

[root@codebase ~]# env | grep jupyter
[root@codebase ~]# 
[root@codebase ~]# source ~/.bash_profile 
[root@codebase ~]# 
[root@codebase ~]# env | grep jupyter
PATH=/opt/anaconda3/bin/jupyter:/opt/anaconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/root/bin
[root@codebase ~]# 

看看命令【jupyter】

[root@codebase ~]# jupyter -h
usage: jupyter [-h] [--version] [--config-dir] [--data-dir] [--runtime-dir]
               [--paths] [--json]
               [subcommand]

Jupyter: Interactive Computing

positional arguments:
  subcommand     the subcommand to launch

optional arguments:
  -h, --help     show this help message and exit
  --version      show the jupyter command's version and exit
  --config-dir   show Jupyter config dir
  --data-dir     show Jupyter data dir
  --runtime-dir  show Jupyter runtime dir
  --paths        show all Jupyter paths. Add --json for machine-readable
                 format.
  --json         output paths as machine-readable json

Available subcommands: bundlerextension console kernel kernelspec lab
labextension labhub migrate nbconvert nbextension notebook qtconsole run
serverextension troubleshoot trust
[root@codebase ~]# 

运行jupyter notebook:

[root@codebase ~]# ps -ef | grep jupyter
root      4730  2784  0 16:32 pts/0    00:00:00 grep --color=auto jupyter
[root@codebase ~]# 
[root@codebase ~]# jupyter
jupyter                   jupyter-kernelspec        jupyter-migrate           jupyter-qtconsole         jupyter-trust
jupyter-bundlerextension  jupyter-lab               jupyter-nbconvert         jupyter-run               
jupyter-console           jupyter-labextension      jupyter-nbextension       jupyter-serverextension   
jupyter-kernel            jupyter-labhub            jupyter-notebook          jupyter-troubleshoot      
[root@codebase ~]# 
[root@codebase ~]# jupyter notebook
[I 16:33:12.949 NotebookApp] Writing notebook server cookie secret to /run/user/0/jupyter/notebook_cookie_secret
[I 16:33:13.325 NotebookApp] JupyterLab extension loaded from /opt/anaconda3/lib/python3.7/site-packages/jupyterlab
[I 16:33:13.325 NotebookApp] JupyterLab application directory is /opt/anaconda3/share/jupyter/lab
[C 16:33:13.327 NotebookApp] Running as root is not recommended. Use --allow-root to bypass.
[root@codebase ~]# 
[root@codebase ~]# ps -ef | grep jupyter
root      4736  2784  0 16:33 pts/0    00:00:00 grep --color=auto jupyter
[root@codebase ~]# 

默认不建议用root运行。

不过可以通过命令选项跳过:

[root@codebase ~]# ps -ef | grep jupyter
root      4750  2784  0 16:33 pts/0    00:00:00 grep --color=auto jupyter
[root@codebase ~]# 
[root@codebase ~]# jupyter notebook --allow-root
[I 16:33:59.069 NotebookApp] JupyterLab extension loaded from /opt/anaconda3/lib/python3.7/site-packages/jupyterlab
[I 16:33:59.069 NotebookApp] JupyterLab application directory is /opt/anaconda3/share/jupyter/lab
[I 16:33:59.072 NotebookApp] Serving notebooks from local directory: /root
[I 16:33:59.072 NotebookApp] The Jupyter Notebook is running at:
[I 16:33:59.072 NotebookApp] http://localhost:8888/?token=99b84c4903598e04f0832089c7fc6db776114f9083e1353b
[I 16:33:59.072 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[W 16:33:59.078 NotebookApp] No web browser found: could not locate runnable browser.
[C 16:33:59.078 NotebookApp] 
    
    To access the notebook, open this file in a browser:
        file:///run/user/0/jupyter/nbserver-4751-open.html
    Or copy and paste one of these URLs:
        http://localhost:8888/?token=99b84c4903598e04f0832089c7fc6db776114f9083e1353b

查看下系统进程与端口状态:

[root@codebase ~]# ps -ef | grep jupyter
root      4751  2784  1 16:33 pts/0    00:00:01 /opt/anaconda3/bin/python /opt/anaconda3/bin/jupyter-notebook --allow-root
root      4851  4763  0 16:35 pts/1    00:00:00 grep --color=auto jupyter
[root@codebase ~]# 
[root@codebase ~]# netstat -tupln | grep python
tcp        0      0 127.0.0.1:8888          0.0.0.0:*               LISTEN      4751/python         
tcp6       0      0 ::1:8888                :::*                    LISTEN      4751/python         
[root@codebase ~]# 

访问URL:
http://10.158.1.45:8888


如果你直接通过8888端口进来的,你就会看到上面截图的画面,需要你提供token,才可以走下一步。

token是什么呢?
其实在前面,【jupyter notebook】的运行界面的log中可以看得到。

你也可以通过命令查看到:

[root@codebase ~]# jupyter notebook list
Currently running servers:
http://localhost:8888/?token=99b84c4903598e04f0832089c7fc6db776114f9083e1353b :: /root
[root@codebase ~]# 

上面截图的画面中,将后面的token给进去,就能登陆了。

或者,更方便的,直接将上面list中的URL,填到浏览器中访问。

这样JUPYTER NOTEBOOK的安装就完成了。

配置JUPYTER NOTEBOOK。
前面的运行是使用的默认配置,因此,它只能在JUPYTER的本机访问,其他机器是无法访问到的。

因此,需要对配置做出一些改变。

下面开始。
——————————

[root@codebase ~]# mkdir /jupyter_notebook_data
[root@codebase ~]# 
[root@codebase ~]# cd /jupyter_notebook_data/
[root@codebase jupyter_notebook_data]# 
[root@codebase jupyter_notebook_data]# jupyter notebook list
Currently running servers:
[root@codebase jupyter_notebook_data]# 
[root@codebase jupyter_notebook_data]# jupyter notebook -h
The Jupyter HTML Notebook.

This launches a Tornado based HTML Notebook Server that serves up an
HTML5/Javascript Notebook client.

Subcommands
-----------

Subcommands are launched as `jupyter-notebook cmd [args]`. For information on
using subcommand 'cmd', do: `jupyter-notebook cmd -h`.

list
    List currently running notebook servers.
stop
    Stop currently running notebook server for a given port
password
    Set a password for the notebook server.

Options
-------

Arguments that take values are actually convenience aliases to full
Configurables, whose aliases are listed on the help line. For more information
on full configurables, see '--help-all'.

--debug
    set log level to logging.DEBUG (maximize logging output)
--generate-config
    generate default config file
-y
    Answer yes to any questions instead of prompting.
--no-browser
    Don't open the notebook in a browser after startup.
--pylab
    DISABLED: use %pylab or %matplotlib in the notebook to enable matplotlib.
--no-mathjax
    Disable MathJax
    
    MathJax is the javascript library Jupyter uses to render math/LaTeX. It is
    very large, so you may want to disable it if you have a slow internet
    connection, or for offline use of the notebook.
    
    When disabled, equations etc. will appear as their untransformed TeX source.
--allow-root
    Allow the notebook to be run from root user.
--script
    DEPRECATED, IGNORED
--no-script
    DEPRECATED, IGNORED
--log-level= (Application.log_level)
    Default: 30
    Choices: (0, 10, 20, 30, 40, 50, 'DEBUG', 'INFO', 'WARN', 'ERROR', 'CRITICAL')
    Set the log level by value or name.
--config= (JupyterApp.config_file)
    Default: ''
    Full path of a config file.
--ip= (NotebookApp.ip)
    Default: 'localhost'
    The IP address the notebook server will listen on.
--port= (NotebookApp.port)
    Default: 8888
    The port the notebook server will listen on.
--port-retries= (NotebookApp.port_retries)
    Default: 50
    The number of additional ports to try if the specified port is not
    available.
--transport= (KernelManager.transport)
    Default: 'tcp'
    Choices: ['tcp', 'ipc']
--keyfile= (NotebookApp.keyfile)
    Default: ''
    The full path to a private key file for usage with SSL/TLS.
--certfile= (NotebookApp.certfile)
    Default: ''
    The full path to an SSL/TLS certificate file.
--client-ca= (NotebookApp.client_ca)
    Default: ''
    The full path to a certificate authority certificate for SSL/TLS client
    authentication.
--notebook-dir= (NotebookApp.notebook_dir)
    Default: ''
    The directory to use for notebooks and kernels.
--browser= (NotebookApp.browser)
    Default: ''
    Specify what command to use to invoke a web browser when opening the
    notebook. If not specified, the default browser will be determined by the
    `webbrowser` standard library module, which allows setting of the BROWSER
    environment variable to override it.
--pylab= (NotebookApp.pylab)
    Default: 'disabled'
    DISABLED: use %pylab or %matplotlib in the notebook to enable matplotlib.

To see all available configurables, use `--help-all`

Examples
--------

    jupyter notebook                       # start the notebook
    jupyter notebook --certfile=mycert.pem # use SSL/TLS certificate
    jupyter notebook password              # enter a password to protect the server

[root@codebase jupyter_notebook_data]# 
[root@codebase jupyter_notebook_data]# jupyter notebook --generate-config
Overwrite /root/.jupyter/jupyter_notebook_config.py with default config? [y/N]y  
Writing default config to: /root/.jupyter/jupyter_notebook_config.py
[root@codebase jupyter_notebook_data]# 

上面:
1. 创建了jupyter notebook的工作目录
2. 生成了一个配置文件:【jupyter_notebook_config.py】

编辑配置文件:

[root@codebase jupyter_notebook_data]# cat /root/.jupyter/jupyter_notebook_config.py | grep -v "^#" | strings
[root@codebase jupyter_notebook_data]# 
[root@codebase jupyter_notebook_data]# vi /root/.jupyter/jupyter_notebook_config.py
[root@codebase jupyter_notebook_data]# cat /root/.jupyter/jupyter_notebook_config.py | grep -v "^#" | strings
c.NotebookApp.ip = '10.158.1.45'
[root@codebase jupyter_notebook_data]# 

再次运行(放到后台)

[root@codebase ~]# jupyter notebook password
Enter password: 
Verify password: 
[NotebookPasswordApp] Wrote hashed password to /root/.jupyter/jupyter_notebook_config.json
[root@codebase ~]# 
[root@codebase ~]# nohup jupyter notebook --notebook-dir=/jupyter_notebook_data --allow-root &
[1] 5705
[root@codebase ~]# nohup: ignoring input and appending output to ‘nohup.out’

[root@codebase ~]# 

看看运行状态:

[root@codebase ~]# ps -ef | grep jupyter
root      5705  2784  3 17:12 pts/0    00:00:01 /opt/anaconda3/bin/python /opt/anaconda3/bin/jupyter-notebook --notebook-dir=/jupyter_notebook_data --allow-root
root      5713  2784  0 17:13 pts/0    00:00:00 grep --color=auto jupyter
[root@codebase ~]# 
[root@codebase ~]# netstat -tupln | grep python
tcp        0      0 10.158.1.45:8888        0.0.0.0:*               LISTEN      5705/python         
[root@codebase ~]# 
[root@codebase ~]# jupyter notebook list
Currently running servers:
http://10.158.1.45:8888/ :: /jupyter_notebook_data
[root@codebase ~]# 

页面访问:
http://10.158.1.45:8888

使用一下:
使用前:

[root@codebase ~]# ls -ltra /jupyter_notebook_data/
total 0
dr-xr-xr-x. 19 root root 269 Jan 10 17:00 ..
drwxr-xr-x   2 root root   6 Jan 10 17:00 .
[root@codebase ~]# 

使用后:

[root@codebase ~]# ls -ltra /jupyter_notebook_data/
total 4
dr-xr-xr-x. 19 root root 269 Jan 10 17:00 ..
-rw-r--r--   1 root root  72 Jan 10 17:16 Untitled.ipynb
drwxr-xr-x   3 root root  54 Jan 10 17:16 .
drwxr-xr-x   2 root root  39 Jan 10 17:16 .ipynb_checkpoints
[root@codebase ~]# 
[root@codebase ~]# cat /jupyter_notebook_data/Untitled.ipynb 
{
 "cells": [],
 "metadata": {},
 "nbformat": 4,
 "nbformat_minor": 2
}
[root@codebase ~]#

至此,Jupyter Notebook的安装与简单使用,就说完了。

——————————
Done

说点什么

avatar

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据

  Subscribe  
提醒