解决 jupyter labextension install 报错

解决 jupyter labextension install 报错

Jupyter Lab 插件安装

# 查询安装的扩展
jupyter labextension list

# 命令行安装对应的扩展
jupyter labextension install @jupyterlab/git
jupyter labextension install @jupyterlab/github
jupyter labextension install @jupyterlab/debugger
jupyter labextension install @krassowski/jupyterlab-lsp
jupyter labextension install @lckr/jupyterlab_variableinspector

# 或者直接通过juputer lab插件管理安装
# 进入jupyter界面,点击插件图标
# 在搜索栏中搜索对应插件名,如jupytext,可直接安装插件

# 删除扩展
jupyter labextension uninstall my-extension

插件推荐

jupyterlab_code_formatter  自动格式化代码   
jupytext                   ipynb\py\md文件互相转换
jupyterlab_spellchecker    markdown拼写核对
@krassowski/jupyterlab-lsp 自动补全与跳转定义
@jupyterlab/github         
@jupyterlab/git     

安装时报错信息

λ jupyter labextension install @jupyterlab/toc
Building jupyterlab assets (build:prod:minimize)
|Exception in thread Thread-10:
Traceback (most recent call last):
  File "e:\python\python36\lib\threading.py", line 916, in _bootstrap_inner
    self.run()
  File "e:\python\python36\lib\threading.py", line 864, in run
    self._target(*self._args, **self._kwargs)
  File "e:\python\python36\lib\subprocess.py", line 1083, in _readerthread
    buffer.append(fh.read())
UnicodeDecodeError: 'gbk' codec can't decode byte 0xa4 in position 281: illegal multibyte sequence

An error occured.
IndexError: list index out of range
See the log file for details:  C:\Users\*****\AppData\Local\Temp\jupyterlab-debug-kx1tois9.log

主要是这句话:UnicodeDecodeError: 'gbk' codec can't decode byte 0xa4 in position 281: illegal multibyte sequence

解决办法

找到python安装目录的lib\site-packages\jupyterlab\commands.py文件,
第83行:

   self.proc = self._create_process(
        cwd=cwd,
        env=env,
        stderr=subprocess.STDOUT,
        stdout=subprocess.PIPE,
        universal_newlines=True
    )

修改为:

    self.proc = self._create_process(
        cwd=cwd,
        env=env,
        stderr=subprocess.STDOUT,
        stdout=subprocess.PIPE,
        universal_newlines=True,
        encoding="UTF-8"
    )

也就是增加一个参数encoding=“UTF-8”,就可以了。

参考:https://zhuanlan.zhihu.com/p/104143118

https://blog.csdn.net/qq_15988503/article/details/108445949

posted @ 2020-09-11 15:51  banshaohuan  阅读(6887)  评论(2编辑  收藏  举报