jupyter labextension install @jupyterlab/toc 安装报错

jupyter labextension install @jupyterlab/toc 安装报错

      • Jupyter Lab 插件安装
      • 错误信息
      • 日志文件
      • 解决办法

Jupyter Lab 插件安装

jupyter labextension install @jupyterlab/toc

错误信息

λ 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

日志文件

Node v12.18.0

Yarn configuration loaded.
> "C:\Program Files\nodejs\npm.CMD" pack @jupyterlab/toc
npm notice 
npm notice package: @jupyterlab/[email protected]
npm notice === Tarball Contents === 
npm notice 1.5kB LICENSE                                                
npm notice 9.3kB style/index.css                                        
npm notice 2.6kB lib/generators/notebook/append_collapsible_heading.js  
npm notice 1.4kB lib/generators/notebook/append_heading.js              
npm notice 1.4kB lib/generators/notebook/append_markdown_heading.js     
npm notice 1.3kB lib/generators/notebook/codemirror.js                  
npm notice 5.4kB lib/extension.js                                       
npm notice 1.4kB lib/utils/generate_numbering.js                        
npm notice 1.2kB lib/generators/notebook/get_code_cell_heading.js       
npm notice 1.6kB lib/generators/markdown/get_headings.js                
npm notice 663B  lib/generators/notebook/get_last_heading_level.js      
npm notice 1.3kB lib/generators/notebook/get_markdown_heading.js        
npm notice 2.3kB lib/generators/markdown/get_rendered_headings.js       
npm notice 2.3kB lib/generators/notebook/get_rendered_html_heading.js   
npm notice 180B  lib/utils/headings.js                                  
npm notice 443B  lib/generators/index.js                                
npm notice 2.9kB lib/generators/latex/index.js                          
npm notice 4.1kB lib/generators/markdown/index.js                       
npm notice 6.9kB lib/generators/notebook/index.js                       
npm notice 4.9kB lib/generators/notebook/tagstool/index.js              
npm notice 2.5kB lib/generators/python/index.js                         
npm notice 377B  lib/index.js                                           
npm notice 675B  lib/utils/is_dom.js                                    
npm notice 1.0kB lib/generators/notebook/is_heading_filtered.js         
npm notice 764B  lib/utils/is_markdown.js                               
npm notice 180B  lib/utils/numbering_dictionary.js                      
npm notice 1.3kB lib/generators/markdown/options_manager.js             
npm notice 4.4kB lib/generators/notebook/options_manager.js             
npm notice 2.2kB lib/utils/parse_heading.js                             
npm notice 1.9kB lib/registry.js                                        
npm notice 1.1kB lib/generators/markdown/render.js                      
npm notice 5.0kB lib/generators/notebook/render.js                      
npm notice 561B  lib/generators/python/render.js                        
npm notice 1.1kB lib/utils/sanitizer_options.js                         
npm notice 6.7kB lib/generators/notebook/set_collapsed_state.js         
npm notice 2.3kB lib/generators/notebook/tagstool/tag_list.js           
npm notice 870B  lib/generators/notebook/tagstool/tag.js                
npm notice 903B  lib/toc_item.js                                        
npm notice 1.1kB lib/toc_tree.js                                        
npm notice 4.2kB lib/toc.js                                             
npm notice 2.1kB lib/generators/markdown/toolbar_generator.js           
npm notice 7.9kB lib/generators/notebook/toolbar_generator.js           
npm notice 1.3kB lib/generators/notebook/twist_button.js                
npm notice 2.2kB package.json                                           
npm notice 376B  schema/plugin.json                                     
npm notice 1.5kB README.md                                              
npm notice 559B  style/img/autonumbering_darktheme.svg                  
npm notice 343B  style/img/autonumbering.svg                            
npm notice 264B  style/img/check.svg                                    
npm notice 320B  style/img/code_darktheme.svg                           
npm notice 305B  style/img/code.svg                                     
npm notice 669B  style/img/eyeball_hidden.svg                           
npm notice 619B  style/img/eyeball_hover.svg                            
npm notice 617B  style/img/eyeball_view.svg                             
npm notice 625B  style/list-dark.svg                                    
npm notice 625B  style/list-light.svg                                   
npm notice 357B  style/img/markdown_darktheme.svg                       
npm notice 363B  style/img/markdown.svg                                 
npm notice 264B  style/img/menu_arrow.svg                               
npm notice 523B  style/img/numbering.svg                                
npm notice 762B  style/img/tag_darktheme.svg                            
npm notice 1.2kB style/img/tag.svg                                      
npm notice 202B  style/img/toggle_down_darktheme.svg                    
npm notice 181B  style/img/toggle_down.svg                              
npm notice 189B  style/img/toggle_right_darktheme.svg                   
npm notice 187B  style/img/toggle_right.svg                             
npm notice 732B  lib/generators/notebook/append_collapsible_heading.d.ts
npm notice 598B  lib/generators/notebook/append_heading.d.ts            
npm notice 836B  lib/generators/notebook/append_markdown_heading.d.ts   
npm notice 1.2kB lib/generators/notebook/codemirror.d.ts                
npm notice 338B  lib/extension.d.ts                                     
npm notice 425B  lib/utils/generate_numbering.d.ts                      
npm notice 794B  lib/generators/notebook/get_code_cell_heading.d.ts     
npm notice 700B  lib/generators/markdown/get_headings.d.ts              
npm notice 316B  lib/generators/notebook/get_last_heading_level.d.ts    
npm notice 771B  lib/generators/notebook/get_markdown_heading.d.ts      
npm notice 698B  lib/generators/markdown/get_rendered_headings.d.ts     
npm notice 1.0kB lib/generators/notebook/get_rendered_html_heading.d.ts 
npm notice 1.4kB lib/utils/headings.d.ts                                
npm notice 107B  lib/generators/index.d.ts                              
npm notice 529B  lib/generators/latex/index.d.ts                        
npm notice 1.3kB lib/generators/markdown/index.d.ts                     
npm notice 788B  lib/generators/notebook/index.d.ts                     
npm notice 2.2kB lib/generators/notebook/tagstool/index.d.ts            
npm notice 533B  lib/generators/python/index.d.ts                       
npm notice 51B   lib/index.d.ts                                         
npm notice 460B  lib/utils/is_dom.d.ts                                  
npm notice 430B  lib/generators/notebook/is_heading_filtered.d.ts       
npm notice 466B  lib/utils/is_markdown.d.ts                             
npm notice 228B  lib/utils/numbering_dictionary.d.ts                    
npm notice 1.3kB lib/generators/markdown/options_manager.d.ts           
npm notice 3.4kB lib/generators/notebook/options_manager.d.ts           
npm notice 1.4kB lib/utils/parse_heading.d.ts                           
npm notice 3.3kB lib/registry.d.ts                                      
npm notice 402B  lib/generators/markdown/render.d.ts                    
npm notice 530B  lib/generators/notebook/render.d.ts                    
npm notice 269B  lib/generators/python/render.d.ts                      
npm notice 469B  lib/utils/sanitizer_options.d.ts                       
npm notice 572B  lib/generators/notebook/set_collapsed_state.d.ts       
npm notice 1.5kB lib/generators/notebook/tagstool/tag_list.d.ts         
npm notice 913B  lib/generators/notebook/tagstool/tag.d.ts              
npm notice 834B  lib/toc_item.d.ts                                      
npm notice 1.1kB lib/toc_tree.d.ts                                      
npm notice 2.1kB lib/toc.d.ts                                           
npm notice 2.4kB lib/generators/markdown/toolbar_generator.d.ts         
npm notice 3.5kB lib/generators/notebook/toolbar_generator.d.ts         
npm notice 572B  lib/generators/notebook/twist_button.d.ts              
npm notice === Tarball Details === 
npm notice name:          @jupyterlab/toc                         
npm notice version:       4.0.0                                   
npm notice filename:      jupyterlab-toc-4.0.0.tgz                
npm notice package size:  33.5 kB                                 
npm notice unpacked size: 158.2 kB                                
npm notice shasum:        9b20370dba5a195165ff0d6f541ffc2191818ee6
npm notice integrity:     sha512-bruRUaFw76G6P[...]BHgE63eddLy7w==
npm notice total files:   107                                     
npm notice 
jupyterlab-toc-4.0.0.tgz

Node v12.18.0

Yarn configuration loaded.
Building jupyterlab assets (build:prod:minimize)
> node e:\python\python36\lib\site-packages\jupyterlab\staging\yarn.js install --non-interactive
yarn install v1.21.1
[1/5] Validating package.json...
[2/5] Resolving packages...
success Already up-to-date.
Done in 0.48s.

> node e:\python\python36\lib\site-packages\jupyterlab\staging\yarn.js yarn-deduplicate -s fewer --fail
yarn run v1.21.1
$ e:\python\python36\share\jupyter\lab\staging\node_modules\.bin\yarn-deduplicate -s fewer --fail
Done in 0.41s.

> node e:\python\python36\lib\site-packages\jupyterlab\staging\yarn.js run build:prod:minimize
Traceback (most recent call last):

  File "e:\python\python36\lib\site-packages\jupyterlab\debuglog.py", line 47, in debug_logging
    yield

  File "e:\python\python36\lib\site-packages\jupyterlab\labextensions.py", line 105, in start
    command=command, app_options=app_options)

  File "e:\python\python36\lib\site-packages\jupyterlab\commands.py", line 460, in build
    command=command, clean_staging=clean_staging)

  File "e:\python\python36\lib\site-packages\jupyterlab\commands.py", line 657, in build
    ret = self._run(['node', YARN_PATH, 'run', command], cwd=staging)

  File "e:\python\python36\lib\site-packages\jupyterlab\commands.py", line 1752, in _run
    return proc.wait()

  File "e:\python\python36\lib\site-packages\jupyterlab\commands.py", line 107, in wait
    out, _ = proc.communicate(timeout=.1)

  File "e:\python\python36\lib\subprocess.py", line 863, in communicate
    stdout, stderr = self._communicate(input, endtime, timeout)

  File "e:\python\python36\lib\subprocess.py", line 1133, in _communicate
    stdout = stdout[0]

IndexError: list index out of range

Exiting application: jupyter

解决办法

找到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”,就可以了

你可能感兴趣的:(jupyterleb)