Linux安装 Jupyter Notebook 并配置任意IP密码访问

Linux安装 Jupyter Notebook 并配置任意IP密码访问

文章目录

  • Linux安装 Jupyter Notebook 并配置任意IP密码访问
    • 1. 下载安装包
    • 2. 安装
    • 3. 配置
      • 3.1 生成jupyter配置文件
      • 3.1 生成哈希密码
      • 3.3 修改配置文件
      • 3.4 配置文件中的其他可配置选项

1. 下载安装包

https://www.anaconda.com/products/individual

Linux安装 Jupyter Notebook 并配置任意IP密码访问_第1张图片
我这里下载Linux 64位版本的
也可以在终端直接输入以下命令进行下载:

wget https://repo.anaconda.com/archive/Anaconda3-2020.02-Linux-x86_64.sh

2. 安装

sh Anaconda3-2020.02-Linux-x86_64.sh

q回车

Welcome to Anaconda3 2020.02
In order to continue the installation process, please review the license
agreement.
Please, press ENTER to continue
>>>

按Enter

Anaconda reserves all rights not expressly granted to you in this Agreement.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the followi
ng conditions are met:

  * Redistributions of source code must retain the above copyright notice, this list of conditions and the following dis

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

输入yes回车

Anaconda3 will now be installed into this location:
/home/jupyter/anaconda3

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

按Enter

Preparing transaction: done
Executing transaction: done
installation finished.
Do you wish the installer to initialize Anaconda3
by running conda init? [yes|no]
[no] >>>

输入yes回车
在终端输入以下两条命令

touch ~/.condarc
source ~/.bashrc

在命令行输入jupyter notebook 即可进入notebook
Ctrl + C停止运行

3. 配置

3.1 生成jupyter配置文件

jupyter notebook --generate-config --allow-root

此时会返回给我们配置文件的位置
Writing default config to: /home/jupyter/.jupyter/jupyter_notebook_config.py

3.1 生成哈希密码

$ ipython

Python 3.7.6 (default, Jan  8 2020, 19:59:22)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.12.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: from notebook.auth import passwd

In [2]:passwd()
Enter password:
Verify password:
Out[2]: 'sha1:9b54xxxxd0d5:694b082faxxxc1862f969170f211xxx5b9xxxxee' 

得到一串哈希密码

3.3 修改配置文件

打开3.1中生成的这个配置文件

vi ~/.jupyter/jupyter_notebook_config.py
  • 修改密码
    找到#c.NotebookApp.password = ''
    去掉前面的#,在引号中输入刚才生成的哈希密码

  • 更改端口
    c.NotebookApp.port = 8888,端口改为8888

  • 任何IP可访问
    修改:#c.NotebookApp.ip = 'localhost'
    变为:c.NotebookApp.ip = '*'

ESC+:wq保存退出。

3.4 配置文件中的其他可配置选项

c.NotebookApp.notebook_dir ='' #配置jupyter文件夹的目录

你可能感兴趣的:(Python,Jupyter,Linux基础,linux,python,anaconda,ubuntu)