JupyterLab安装

JupyterLab安装

  • 创新虚拟环境
  • JupyterLab安装
    • 安装
    • 配置
    • 启动
    • 设置访问密码

创新虚拟环境

在进行JupyterLab的安装之前,为了环境隔离,需要创建一个Python的虚拟环境,Python虚拟环境的创建,可以参考Python虚拟环境,并激活虚拟环境。

JupyterLab安装

安装

JupyterLab的安装比较简单,执行以下命令安装JupyterLab。

pip install jupyterlab
# 如果下载速度慢,可以指定国内的镜像加速
pip install jupyterlab -i https://pypi.tuna.tsinghua.edu.cn/simple

JupyterLab安装_第1张图片

安装完成后,会提示安装成功,并列出安装了哪些库。

JupyterLab安装_第2张图片

$ pip list
Package                  Version    
------------------------ -----------
anyio                    3.6.2      
argon2-cffi              21.3.0     
argon2-cffi-bindings     21.2.0     
asttokens                2.2.1      
attrs                    22.1.0     
Babel                    2.11.0     
backcall                 0.2.0      
beautifulsoup4           4.11.1     
bleach                   5.0.1      
certifi                  2022.12.7  
cffi                     1.15.1     
charset-normalizer       2.1.1      
comm                     0.1.2      
debugpy                  1.6.4      
decorator                5.1.1      
defusedxml               0.7.1      
entrypoints              0.4        
executing                1.2.0      
fastjsonschema           2.16.2     
idna                     3.4        
importlib-metadata       5.1.0      
importlib-resources      5.10.1     
ipykernel                6.19.2     
ipython                  8.7.0      
ipython-genutils         0.2.0      
jedi                     0.18.2     
Jinja2                   3.1.2      
json5                    0.9.10     
jsonschema               4.17.3     
jupyter-client           7.4.8      
jupyter-core             5.1.0      
jupyter-events           0.5.0      
jupyter-server           2.0.1      
jupyter-server-terminals 0.4.2      
jupyterlab               3.5.1      
jupyterlab-pygments      0.2.2      
jupyterlab-server        2.16.5     
MarkupSafe               2.1.1      
matplotlib-inline        0.1.6      
mistune                  2.0.4      
nbclassic                0.4.8      
nbclient                 0.7.2      
nbconvert                7.2.6      
nbformat                 5.7.0      
nest-asyncio             1.5.6      
notebook                 6.5.2      
notebook-shim            0.2.2      
packaging                22.0       
pandocfilters            1.5.0      
parso                    0.8.3      
pexpect                  4.8.0      
pickleshare              0.7.5      
pip                      20.0.2     
pkg-resources            0.0.0      
pkgutil-resolve-name     1.3.10     
platformdirs             2.6.0      
prometheus-client        0.15.0     
prompt-toolkit           3.0.36     
psutil                   5.9.4      
ptyprocess               0.7.0      
pure-eval                0.2.2      
pycparser                2.21       
Pygments                 2.13.0     
pyrsistent               0.19.2     
python-dateutil          2.8.2      
python-json-logger       2.0.4      
pytz                     2022.6     
PyYAML                   6.0        
pyzmq                    24.0.1     
requests                 2.28.1     
Send2Trash               1.8.0      
setuptools               44.0.0     
six                      1.16.0     
sniffio                  1.3.0      
soupsieve                2.3.2.post1
stack-data               0.6.2      
terminado                0.17.1     
tinycss2                 1.2.1      
tomli                    2.0.1      
tornado                  6.2        
traitlets                5.7.1      
urllib3                  1.26.13    
wcwidth                  0.2.5      
webencodings             0.5.1      
websocket-client         1.4.2      
zipp                     3.11.0

配置

安装完成后,JupyterLab默认只能是localhost访问,为了保证可以通过网络访问JupyterLab,需要对它进行一些配置,执行以下命令,并修改配置文件~/.jupyter/jupyter_lab_config.py中关于限制IP地址的配置项c.ServerApp.ip = ‘*’,以便可以通过网络访问。
执行以下命令创建配置文件,并编辑配置文件中的配置项。

jupyter lab --generate-config

vi ~/.jupyter/jupyter_lab_config.py

在这里插入图片描述
编辑配置项。
在这里插入图片描述

启动

配置完成以后,可以执行以下命令来启动JupyterLab。

jupyter lab

JupyterLab安装_第3张图片
此时,可以通过Token访问以下地址来访问JupyterLab。

http://localhost:8888/lab?token=4c73c48660a137a56a318be33c19f9edc594ed1fa3cd14d2
http://127.0.0.1:8888/lab?token=4c73c48660a137a56a318be33c19f9edc594ed1fa3cd14d2

当然,由于我们配置了c.ServerApp.ip = ‘*’,所以也可以通过远程进行访问。

http://wux-labs-vm.internal.cloudapp.net:8888/lab?token=4c73c48660a137a56a318be33c19f9edc594ed1fa3cd14d2

JupyterLab安装_第4张图片

看到首页后,说明JupyterLab安装启动成功,并且能够远程访问了。下面可以创建notebook、编写代码并运行。
JupyterLab安装_第5张图片

设置访问密码

虽然目前可以通过带Token的地址访问JupyterLab了,但是每次访问都带上Token不仅很麻烦,而且还不好记住,并且每次重启JupyterLab后Token还不一样,所以我们还是希望不带Token直接访问。

http://wux-labs-vm.internal.cloudapp.net:8888/lab

此时,访问地址没有带Token,则无法直接访问主页,JupyterLab要求我们提供Token或者密码。

JupyterLab安装_第6张图片

在页面底端,输入Token、设置密码,随后就可以用密码进行登录访问了。
JupyterLab安装_第7张图片

当下次再进行访问的时候,只需要简单的输入设置的密码就可以进行访问了。

JupyterLab安装_第8张图片

编码、运行都没有问题。

JupyterLab安装_第9张图片

你可能感兴趣的:(#,Python环境安装,python,开发语言)