jupyter及常用插件

配置虚拟环境

pip设置清华源

pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

安装virtualenv和virtualenvwrapper

pip install virtualenv
sudo pip install virtualenvwrapper

创建jupyter虚拟环境

mkvirtualenv jupyter

进入jupyter虚拟环境

workon jupyter

退出虚拟环境

deactivate

配置环境变量

export WORKON_HOME=~/.virtualenvs                                                                     
export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python                                                       
export VIRTUALENVWRAPPER_VIRTUALENV=/usr/local/python3.9.4/bin/virtualenv                             
source /usr/local/python3.9.4/bin/virtualenvwrapper.sh

安装jupyterlab

进入jupyter虚拟环境后,安装jupyterlab

pip install jupyterlab

生成密钥

ipython 
from notebook.auth import passwd
passwd()

输入和确认密钥

生成配置文件

jupyter lab --generate-config

用vim编辑器打开生成的配置文件

vim ~/.jupyter/jupyter_notebook_config.py

设置配置文件

c.ServerApp.ip = '*'
# 这里的密码填写上面生成的密钥
c.ServerApp.password = '密钥' 
# 禁止用host的浏览器打开jupyter
c.ServerApp.open_browser = False 
# 打开jupyter lab的端口
c.ServerApp.port = 7238
# 允许远程访问 
c.ServerApp.allow_remote_access = True

启动jupyterlab

jupyter lab  --allow-root

插件安装

代码可视化(nbtutor)

目前,nbtutor暂时只能在jupyter notebook中使用,在jupyterlab中还没找到使用方法。官方地址
安装

pip install nbtutor
jupyter nbextension install --overwrite --py nbtutor
jupyter nbextension enable --py nbtutor

测试代码

%%nbtutor -r -f

def partition(arr,low,high): 
    i = ( low-1 )         # 最小元素索引
    pivot = arr[high]     
  
    for j in range(low , high): 
  
        # 当前元素小于或等于 pivot 
        if   arr[j] <= pivot: 
          
            i = i+1 
            arr[i],arr[j] = arr[j],arr[i] 
  
    arr[i+1],arr[high] = arr[high],arr[i+1] 
    return ( i+1 ) 

def quickSort(arr,low,high): 
    if low < high: 
  
        pi = partition(arr,low,high) 
  
        quickSort(arr, low, pi-1) 
        quickSort(arr, pi+1, high) 

arr = [9, 7, 50, 6, 1, 5] 
n = len(arr) 
quickSort(arr,0,n-1) 
print ("排序后的数组:") 
for i in range(n): 
    print ("%d" %arr[i])

在这里插入图片描述

中文插件

pip install jupyterlab-language-pack-zh-CN

在这里插入图片描述

可视化交互

ipympl

pip安装

pip install ipympl

要实现可视化交互,需要使用Jupyter magic

%matplotlib widget

在这里插入图片描述

变量查看器

jupyterlab-variableinspector

pip安装

pip install lckr-jupyterlab-variableinspector

在这里插入图片描述

代码折叠

Collapsible_headings
pip安装

pip install aquirdturtle_collapsible_headings

在这里插入图片描述

内核安装

C内核

pip install jupyter-c-kernel
jupyter nbextension enable --py jupyter-c-kernel
install_c_kernel

查看内核

jupyter labextension list

在这里插入图片描述

常用内核

微信公众号
在这里插入图片描述

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

飞华1993

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值