环境配置 |Jupyter lab/Jupyter Notebook 安装与设置

ipynb使用Jupyterlab/Jupyter Notebook 来编写Python程序时的文件,在使用时,可以现转换为标准的.py的python文件

1.Jupyter Lab

1.1.下载安装

环境:Linux

pip install jupyterlab

1.2.使用

jupyter lab

 点击后进入

 1.3.jupyter lab更换内核

因为我的是在anaconda的虚拟环境进行设置,所以先进入虚拟环境
 

conda activate env

pip install ipykernel

将conda环境写入jupyter的kernel中

--name 环境名称

--display-name 在jupyter lab看到的别名

python -m ipykernel install --user  --name sam --display-name "sam"

 

再进入jupyter

jupyter lab

# jupyter lab --ip=0.0.0.0 --allow-root

在Jupyterlab界面上方的kernel---->change kernel中选择即可。或者新建文件的时候直接选择不同版本的环境

2.Jupyter Notebook

2.1.下载安装

pip install jupyter notebook

#pip install -i https://pypi.tuna.tsinghua.edu.cn/simple jupyter

在conda的虚拟环境中安装

conda install -y jupyter

其他

pip install pyzmq

2.2.使用

jupyter notebook

进入到ipynb文件对应的目录

2.3.jupyter notebook更换内核(与1.3相同)

3.将ipynb文件转化成python文件

jupyter nbconvert --to script *.ipynb

Q&A

Q1:Jupyter Notebook和jupyter lab的区别?

Jupyter Notebook 是一个款以网页为基础的交互计算环境,可以创建Jupyter的文档,支持多种语言,包括Python, Julia, R等等。广泛用于数据分析,数据可视化和其他的交互和探索性计算中。

JupyterLab 是包括了Notebook下一代用户界面。有模块化的界面,可以在同一个窗口同时打开好几个notebook或文件(HTML, TXT, Markdown等等),都以标签的形式展示,于是就更像是一个IDE。

PS

【PS1】安装第三库时出现错误

输入pip install google-colab出现错误

原因分析:觉得是setuptools的版本问题,所以尝试conda安装

conda install -c conda-forge google-colab

安装后问题解决

【PS2】AttributeError: module 'IPython.utils.traitlets' has no attribute 'Unicode'

打开源文件

 ~/anaconda3/envs/sam/lib/python3.8/site-packages/google/colab/data_table.py

将 库里的原本的代码from IPython.utils import traitlets as _traitlets删除或注释掉

改为 import traitlets as _traitlets

 

然后就解决啦~

相关错误ModuleNotFoundError: No module named 'traitlets.config.application'

 将原本的traitlets-5.9.0卸载,再安装就好啦

pip uninstall traitlets==5.9.0

pip install traitlets==5.14.1

【PS3】RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu! (when checking argument for argument mat2 in method wrapper_CUDA_mm)

未解决

【PS4】The Jupyter server will temporarily stop sending output to the client in order to avoid crashing it. To change this limit, set the config variable `--ServerApp.iopub_msg_rate_limit`.

解决办法:

命令行中输入如下:

jupyter lab --NotebookApp.iopub_data_rate_limit=1.0e10

# jupyter lab --allow-root --NotebookApp.iopub_data_rate_limit=1.0e10

即可解决。

或者 在.jupyter目录下找到configure.py,打开,找到如上代码,修改保存即可。

  • 23
    点赞
  • 26
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
安装和配置JupyterLab可以按照以下步骤进行: 1. 首先,从Docker中拉取Miniconda镜像,并从零开始安装。可以使用以下命令: ``` docker pull miniconda ``` 2. 激活Miniconda环境。可以使用以下命令: ``` source activate <环境名称> ``` 3. 使用pip安装JupyterLab。可以使用以下命令: ``` pip install jupyterlab ``` 4. 生成JupyterLab的配置文件。可以使用以下命令: ``` jupyter lab --generate-config ``` 5. 将配置文件复制到指定位置。可以使用以下命令: ``` cp /home/admin555/.jupyter/jupyter_notebook_config.py /指定位置/jupyter_notebook_config.py ``` 6. 完成以上步骤后,您可以启动JupyterLab。可以使用以下命令: ``` jupyter lab ``` 请注意,根据您的操作系统和环境,配置文件的位置可能会有所不同。在Windows系统上,配置文件通常位于`C:\Users\用户名\.jupyter\jupyter_notebook_config.py`,而在Linux系统上,配置文件通常位于`/home/用户名/.jupyter/jupyter_notebook_config.py`。\[1\]\[2\]\[3\] #### 引用[.reference_title] - *1* [jupyter lab安装、配置教程](https://blog.csdn.net/buluxianfeng/article/details/126149522)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control,239^v3^insert_chatgpt"}} ] [.reference_item] - *2* *3* [Jupyter Lab安装、配置、插件推荐、多用户使用教程](https://blog.csdn.net/qq_43701912/article/details/121446837)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

夏天|여름이다

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

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

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

打赏作者

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

抵扣说明:

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

余额充值