You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

执行CocInstall Autopep8命令时Autopep8下载失败,求解决方案

修复CocInstall autopep8下载错误

问题详情

执行CocInstall autopep8时出现下载错误,错误截图如下:
错误截图

我的Vim插件配置(基于vim-plug):

call plug#begin()
Plug 'tell-k/vim-autopep8'
Plug 'plasticboy/vim-markdown'
Plug 'sheerun/vim-polyglot'
Plug 'jiangmiao/auto-pairs'
Plug 'ap/vim-css-color'
Plug 'preservim/nerdtree'
Plug 'ryanoasis/vim-devicons'
Plug 'weirongxu/coc-explorer'
Plug 'dracula/vim'
Plug 'tsony-tsonev/nerdtree-git-plugin'
Plug 'Xuyuanp/nerdtree-git-plugin'
Plug 'scrooloose/nerdtree'
Plug 'tiagofumo/vim-nerdtree-syntax-highlight'
Plug 'gruvbox-community/gruvbox'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'neoclide/coc.nvim'
Plug 'preservim/nerdtree'
Plug 'airblade/vim-gitgutter'
Plug 'tc50cal/vim-terminal'
Plug 'elvessousa/sobrio'
Plug 'glepnir/dashboard-nvim'
Plug 'davidhalter/jedi-vim'
Plug 'mbbill/undotree'
Plug 'junegunn/fzf.vim'
Plug 'tpope/vim-fugitive'
Plug 'cj/vim-webdevicons'
Plug 'powerline/fonts'
Plug 'VSCodeVim/Vim'
Plug 'github/copilot.vim'
Plug 'mbbill/undotree'
Plug 'tpope/vim-fugitive'
Plug 'junegunn/fzf.vim' " Fuzzy Finder, Needs Silversearcher-ag for :Ag
Plug 'RRethy/nvim-base16' " Base16 Color Schemes
Plug 'tpope/vim-surround' " Surrounding ysw)
Plug 'tpope/vim-commentary' " For Commenting gcc & gc
Plug 'RRethy/nvim-base16' " Base16 Color Schemes
Plug 'preservim/tagbar', {'on': 'TagbarToggle'} " Tagbar for code navigation
call plug#end()

自动命令配置:

augroup auto_commands
    autocmd BufWrite *.py call CocAction('format')
    autocmd FileType scss setlocal iskeyword+=@-@
augroup end

augroup fish_syntax
    au!
    autocmd BufNewFile,BufRead *.fish set syntax=sh
augroup end

修复步骤

1. 更新Coc.nvim并检查网络

  • 在Vim中执行:PlugUpdate coc.nvim,确保Coc.nvim为最新版本
  • 终端执行curl -I https://registry.npmjs.org/coc-autopep8,返回200状态码说明网络正常,否则排查代理、防火墙限制

2. 手动安装coc-autopep8

如果CocInstall命令失败,直接通过npm手动安装:

  1. 在Vim中执行:echo g:coc_extensions_root,获取Coc扩展目录(一般为~/.config/coc/extensions)
  2. 终端进入该目录,执行:
    npm install coc-autopep8
    
  3. 重启Vim,执行:CocList extensions确认autopep8已安装

3. 移除冲突插件

配置中同时存在tell-k/vim-autopep8和Coc的autopep8扩展,功能重叠可能引发问题:

  • 删除vim-plug配置中的Plug 'tell-k/vim-autopep8'
  • 执行:PlugClean清理已移除的插件
  • 重启Vim后测试格式化功能

4. 验证与排查

  • 打开Python文件,执行:CocAction('format')测试格式化
  • 若仍有问题,执行:CocOpenLog查看详细错误日志,定位具体问题

内容的提问来源于stack exchange,提问作者Bùi Tiến Hòa

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.20 09:28:13