【Python笔记】Jupyter Notebook 简明指南

本文记录 Jupyter Notebook 的简明使用指南.

1. 安装 Jupyter Notebook

python 3(推荐)

python3 -m pip install --upgrade pip
python3 -m pip install jupyter

python 2

python -m pip install --upgrade pip
python -m pip install jupyter

virtual environment

pip install --upgrade pip
pip install jupyter

2. 运行 Jupyter Notebook

2.1 基本运行命令

点击这里,查看官方指南。

2.2 在服务器上运行

设定为服务器的IP地址,并指定端口号

jupyter notebook --ip xxx.xxx.xxx.xxx --port xxxx

例如,服务器使用的IP为 172.16.2.233,指定端口号为 8888

jupyter notebook --ip 172.16.2.233 --port 8888

    
    Copy/paste this URL into your browser when you connect for the first time,
    to login with a token:
        http://172.16.2.233:8888/?token=277edfd3b1dd827a4641b0901f4b6eecedb0e861729a620d

3. 使用配置文件

3.1生成配置文件
jupyter notebook --generate-config

配置文件路径为:
~/.jupyter/jupyter_notebook_config.py

3.2 生成密钥

打开 python prompt.

from notebook.auth import passwd
passwd()
Enter password: 
Verify password: 
'sha1:feb73cb5561d:ebb2959943c9392da717ee22934da7514f3a441d'
************
3.3 修改配置文件
vim ~/.jupyter/jupyter_notebook_config.py
c.NotebookApp.ip='192.168.2.233'                     # 设置‘*’所有ip皆可访问,或者服务器IP地址
c.NotebookApp.password = u'sha1:feb73cb5561d:ebb2959943c9392da717ee22934da7514f3a441d'       # 刚才复制的那个密文'
c.NotebookApp.open_browser = False       # 禁止自动打开浏览器
c.NotebookApp.port = 8888                 # 指定端口

3.4 按配置文件设置启动
jupyter notebook

4. 安装多内核 IPython kernel

为 Jupyter Notebook 添加 Python 虚拟环境解释器。
Installation Guide

  1. 激活虚拟环境
$ source venv2.7/bin/activate
  1. 安装 ipynernel
(venv2.7) $ pip install ipykernel
  1. 将虚拟环境 Python Interpreter 安装到 Jupyter Notebook
(venv2.7) $ python -m ipykernel install --user --name venv2.7 --display-name "Python2.7(venv2.7)"
Installed kernelspec venv2.7 in /home/homedirectory/.local/share/jupyter/kernels/venv2.7

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值