jupyter lab添加插件可以查看python file中函数定义等

您所在的位置:网站首页 jupyter查看函数 jupyter lab添加插件可以查看python file中函数定义等

jupyter lab添加插件可以查看python file中函数定义等

2024-01-19 00:29| 来源: 网络整理| 查看: 265

文章目录 0. 更新jupyter labOK安装jupyterlab2.3.1版本开启用户验证 折腾0折腾1折腾2 1. jupyterlab-go-to-definition2. lsp插件3. 报错:AttributeError: module 'typing' has no attribute '_SpecialForm'4. Elyra插件5. 目录插件

0. 更新jupyter lab OK 安装jupyterlab2.3.1版本

参考:Failure to start jupyter lab — IndexError: pop from an empty deque

简单来说,就是jupyterlab 3.x版本还不是很稳定,有很多错误,直接降级到2.3.1

conda install jupyterlab=2.3.1

就降级就好了,然后默认打开的jupyterlab里就有jupyter toc插件,但是会提示需要你 build,在界面上点就行了

开启用户验证

但是这种安装好之后,默认没有token和密码设置(没有用户管理),去开一下。 感谢:Invalid Server Password in JupyterLab and Jupyter Notebook

如果是设置jupyter notebook的密码,可以

jupyter notebook password

如果是设置jupyter lab的密码,可以

jupyter server password # 然后就会让你输入密码,再输入密码确认

查看jupyter lab相关路径,可以

$ jupyter lab path Application directory: /opt/conda/share/jupyter/lab User Settings directory: /root/.jupyter/lab/user-settings Workspaces directory: /root/.jupyter/lab/workspaces

但是更好的方式其实是jupyter --path:

$ jupyter --path config: /root/.jupyter # 重点是这个文件夹 /root/.local/etc/jupyter /opt/conda/etc/jupyter /usr/local/etc/jupyter /etc/jupyter data: /root/.local/share/jupyter /opt/conda/share/jupyter /usr/local/share/jupyter /usr/share/jupyter runtime: /root/.local/share/jupyter/runtime

在 /root/.jupyter文件夹中,可以看到

root@XXX$ cd /root/.jupyter/ root@XXX:~/.jupyter$ ls jupyter_notebook_config.json jupyter_server_config.json lab migrated nbconfig

主要就是这两个config文件

jupyter_notebook_config.json - check if there is password setjupyter_server_config.json - check if there is password set

参考:Why I can’t access remote Jupyter Notebook server? 如果启动jupyter lab的时候,显示让访问的端口不是默认的8888,可以在启动的时候添加参数:

jupyter notebook --ip xx.xx.xx.xx --port 8888 # 或者 jupyter lab --ip xx.xx.xx.xx --port 8888 折腾0

可能是因为之前设置过一些什么东西,去看一下jupyterlab的config,参考:Advanced Usage

# 先去看一下jupyter lab的配置文件在哪 root@XXXXXX:/home$ jupyter lab path Application directory: /opt/conda/share/jupyter/lab User Settings directory: /root/.jupyter/lab/user-settings Workspaces directory: /root/.jupyter/lab/workspaces # 查看/root/.jupyter/lab/user-settings的内容(我显示没有这个文件夹。。),但是紧接着在参考文档里看到了 jupyter lab build # 这个代码会rebuild jupyter的app目录,类似重构的感觉吧 [LabBuildApp] WARNING | The extension "jupyterlab_tensorboard" is outdated. [LabBuildApp] WARNING | The extension "jupyterlab-jupytext" is outdated. [LabBuildApp] WARNING | The extension "@jupyterlab/toc" is outdated. 折腾1

报错:AttributeError: 'JupytextContentsManager' object has no attribute 'preferred_dir'

conda update jupyterlab # 如果提示没法安,出现以下内容 PackageNotInstalledError: Package is not installed in prefix. prefix: /opt/conda package name: jupyterlab # 就先用 conda install jupyterlab # 去启动jupyterlab,还是有问题 # 更新所有和jupyter相关的包,先查看自己的jupyter都依赖哪些包 $ jupyter --version Selected Jupyter core packages... IPython : 8.9.0 ipykernel : 6.20.2 ipywidgets : 8.0.4 jupyter_client : 8.0.1 jupyter_core : 5.1.5 jupyter_server : 2.1.0 jupyterlab : 3.5.3 nbclient : 0.7.2 nbconvert : 7.2.9 nbformat : 5.7.3 notebook : 6.5.2 qtconsole : 5.4.0 traitlets : 5.8.1 # 全都更新 pip install --upgrade IPython ipykernel ipywidgets jupyter_client jupyter_core jupyter_server jupyterlab nbclient nbconvert nbformat notebook qtconsole traitlets # 还是不行,继续提示插件extension有问题,那就去更新和插件有关的包 pip install jupyter_contrib_nbextensions && jupyter contrib nbextension install # 还是不行,但是我发现,直接使用jupyter notebook是没问题的,而且启动jupyter notebook服务之后,只需要把 127.0.0.1:8888/tree 换成127.0.0.1:8888/lab # 也可以访问到jupyter lab的页面,但是没法执行代码 # 最后的选择,全部更新,也不知道是什么地方出现了问题,那就全部更新好了。 conda update --all

参考:

How to update jupyterlab using conda or pip 折腾2

建议使用

conda update jupyterlab 如果是使用conda安装的jupyterlab,则不建议使用pip install --upgrade jupyterlab,除非你要暂停conda环境(暂停jupyterlab服务),即:如果使用pip安装,就不是在线更新了,需要重启jupyter 在这里插入图片描述

参考:

stackoverflow:How to update jupyterlab using conda or pip

但是在我实际使用的时候,出现了

$ conda update jupyterlab PackageNotInstalledError: Package is not installed in prefix. prefix: /opt/conda package name: jupyterlab

所以还是使用pip进行了更新(更新了一大坨东西),最后提示需要rebuild jupyter lab,然后崩了。。

最后使用的方式是:

不是在jupyterlab的命令行里进行conda update jupyterlab去容器/服务器本地进行的conda update jupyterlab然后更新完重启jupyter lab就好了

但是重启之后还是安装不上,根据提示: 在这里插入图片描述 去查看extension的版本,显示没有安装。。。继续去安装(参考:Jupyter Notebook Extensions)

pip install jupyter_contrib_nbextensions && jupyter contrib nbextension install

依然提示以上错误,同时发现已有的插件其实也有不兼容的问题 在这里插入图片描述 参考:jupyter lab- Extensions官方文档 需要先安装nodejs

conda install -c conda-forge nodejs

然后就可以使用jupyter labextension命令通过npm来进行扩展包的安装和卸载管理了,例如

jupyter labextension install my-extension my-other-extension # 或者是安装特定的版本 jupyter labextension install [email protected]

使用以下命令:

# 针对这些包 JupyterLab Extension Package >=1.2.1 =3.6.1 =1.2.1 =3.6.1 =1.2.1 =3.6.1 =1.2.2 =3.6.1 =1.2.1 =3.6.1


【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3