You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
PolyglotNotebooksStudy/Docs/安装与配置-Jupyter Notebook.md

104 lines
3.3 KiB
Markdown

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

# Jupyter Notebook安装与配置
## Jupyter Notebook安装
Jupyter(包括JupyterLab)安装环境: windows11 22H2(Windows Server 2022 21H2)、Python 3.11.4、JupyterNote 7.0.2、 JupyterLab 4.0.4
### 前提安装Python(也可以使用Anaconda)
### 可选Node.js JupyterLab插件
### 安装Jupyter
+ 打开`命令行`或`powershell`窗口,最好以管理员身份进入;
+ 进入`Python环境`或者`其他Conda虚拟环境`
```cmd
# python环境不用更改
# Conda虚拟环境选择进入环境
source activate XXXX_虚拟环境名
```
+ 在打开的`命令行`或`powershell`窗口,输入命令
```cmd
pip install jupyter
#或者
conda install -c conda-forge jupyter
#换国内源,加速
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple jupyter
```
+ 启动与验证 `Jupyter Notebook` 使用命令:
```cmd
#查看版本信息
jupyter --version
#启动
jupyter notebook
#正常是启动一个浏览器窗口,报错就是没安装好
```
+ 安装中文语言包:
```cmd
pip install jupyterlab-language-pack-zh-CN
#安装之后,去界面设置中的语言选项,选中 中文
```
### 安装JupyterLab(安装Jupyter后如果已安装JupyterLab则忽略)
+ 打开`命令行`或`powershell`窗口,最好以管理员身份进入;
+ 进入`Python环境`或者`其他Conda虚拟环境`
```cmd
# python环境不用更改
# Conda虚拟环境选择进入环境
source activate XXXX_虚拟环境名
```
+ 在打开的`命令行`或`powershell`窗口,输入命令
```cmd
pip install jupyterlab
#或者
conda install -c conda-forge jupyterlab
```
+ 启动与验证 `JupyterLab` 使用命令:
```cmd
jupyter lab
#正常是启动一个浏览器窗口,报错就是没安装好
```
### 配置 Jupyter
+ 生成配置文件
```cmd
jupyter lab --generate-config
#输出信息说明了生成配置文件的位置下面会更改配置文件来自定义Jupyter
```
+ 配置服务IP和端口及文件目录
```cmd
c.NotebookApp.ip='*' # 如果这里修过过后启动服务报错 则修改为c.NotebookApp.ip='0.0.0.0'
c.NotebookApp.open_browser =False # 设置是否自动打开浏览器
c.NotebookApp.port =8888 # 设置端口
c.NotebookApp.allow_remote_access = True #远程
c.NotebookApp.notebook_dir = 'D:\\Jupyter\\notebooks\\' # Jupyter服务的文件根目录,注意用\\
```
+ 配置密码:
按网上说法执行命令获取密码再配置项是不成功的可能版本比较高了。实际上把启动时生成的地址自带的token去掉直接在浏览器访问网址(http://xx.xxx.xx.xx/tree或http://xx.xx.xx.xx/lab)页面上有设置密码的输入框填写好token与新密码即可生效
强制改密码:如下
```cmd
jupyter lab password
```
### 安装增强功能(自动补全,运行时间之类)
```cmd
#没有亲试过
```
### Jupyter Lab插件设置
首先启动Jupyter Lab在Lab中打开菜单栏的 `Setting`里的`Advanced Setting Editor`,接着找到`Extension Manager`,并在右边填入{'enabled':true}。
界面有启动插件选项时,直接启动插件
### 做成windos服务没有测试过
+ 使用定时任务:开机时执行脚本任务
+ 配置成Windows服务