180807 16步Ubuntu下利用YouCompleteMe配置Anaconda+Vim自动补齐tensorflow+keras+pytorch

参考博客

参考1-让vim支持python3的自动补全【促使我利用YouCompleteMe配置Anaconda环境】
参考2-Ubuntu16.04下配置YouCompleteMe【常规安装套路】
参考3-Ubuntu16.04 为vim安装YouCompleteMe插件【主要参考这篇文章成功安装YCM】
参考4-ycm_core loading issues on Ubuntu 16.04 #2136【在这里找到了Anaconda环境无法识别的原因】
参考5-YouCompleteMe does not work with Anaconda Python #1241【另外一种配置Vim+Anaconda的方法(未实验)】
参考6-Ubuntu16.04 为vim安装YouCompleteMe插件【转载的参考3,内容一模一样】
参考7-一步一步带你安装史上最难安装的 vim 插件 —— YouCompleteMe【评论很多的一篇博客】


安装方法:

  • Step-1:安装vim:sudo apt-get install vim-gtk
  • Step-2:查看vim对python的支持:vim --version | grep python
  • Step-3:安装CMake:sudo apt-get install build-essential cmake
  • Step-4:安装python-dev:sudo apt-get install python-dev python3-dev
  • Step-5:安装YouCompleMegit clone https://github.com/gmarik/Vundle.vim.git ~/.vim/bundle/Vundle.vim
  • Step-6:复制YCM官网vimrc文件到/home根目录下,通过显示隐藏文件查看以及后续编辑操作
set nocompatible              " be iMproved, required
filetype off                  " required

" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')

" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'

" The following are examples of different formats supported.
" Keep Plugin commands between vundle#begin/end.
" plugin on GitHub repo
Plugin 'tpope/vim-fugitive'
" plugin from http://vim-scripts.org/vim/scripts.html
" Plugin 'L9'
" Git plugin not hosted on GitHub
Plugin 'git://git.wincent.com/command-t.git'
" git repos on your local machine (i.e. when working on your own plugin)

" The sparkup vim script is in a subdirectory of this repo called vim.
" Pass the path to set the runtimepath properly.
Plugin 'rstacruz/sparkup', {'rtp': 'vim/'}
" Install L9 and avoid a Naming conflict if you've already installed a
" different version somewhere else.
" Plugin 'ascenator/L9', {'name': 'newL9'}

" cs Plugin
Plugin 'Valloric/YouCompleteMe'

" All of your Plugins must be added before the following line
call vundle#end()            " required
filetype plugin indent on    " required
" To ignore plugin indent changes, instead use:
"filetype plugin on
"
" Brief help
" :PluginList       - lists configured plugins
" :PluginInstall    - installs plugins; append `!` to update or just :PluginUpdate
" :PluginSearch foo - searches for foo; append `!` to refresh local cache
" :PluginClean      - confirms removal of unused plugins; append `!` to auto-approve removal
"
" see :h vundle for more details or wiki for FAQ
" Put your non-Plugin stuff after this line
  • Step-7:在.vimrcbegin/end之间添加PluginInstall 'Valloric/YouCompleteMe'如图所示
  • Step-8:ctrl+alt+T打开terminal输入vim激活打开vim
  • Step-9:键盘输入:PluginInstall就可以开始安装YouCompleteMe.vimrc中的其他插件(网络原因,速度巨慢!)解决方法如下:
    先下载再配置安装:
git clone https://github.com/gmarik/vundle.git ~/.vim/bundle/vundle  
git clone https://github.com/Valloric/YouCompleteMe.git ~/.vim/bundle/YouCompleteMe  
cd ~/.vim/bundle/YouCompleteMe  
git submodule update --init --recursive 
  • Step-10:切换到YouCompleteMe目录
  • Step-11:最重要的一步:利用Anaconda中的python3执行python3 ./install.py文件
    这里写图片描述
    如下图所示,默认状态下的python3Anaconda的python3
    这里写图片描述
  • Step-12:根据需要参考参考3,进行相关配置(感觉非必要)
  • Step-13-1:如果需要vim自动补齐Anaconda自带环境下的site-packages则在.vimrc最后添加下面第一行,并保存
  • Step-13-2:如果需要vim自动补齐Anaconda虚拟环境envs下的site-packages则在.vimrc最后添加下面第二行,并保存
let g:ycm_python_binary_path  = '/home/brucelau/anaconda3/bin/python3.6'

let g:ycm_python_binary_path  = '/home/brucelau/anaconda3/envs/fcn/bin/python3.5'
  • Step-14:利用Vim创建或编辑.py文件
  • Step-15:Tab键可自动显示补齐模块内容

这里写图片描述

  • Step-16:虚拟环境下记得激活虚拟环境source activate envs_name才可运行程序

这里写图片描述

PS:.vimrc文件设置截图
这里写图片描述

  • 1
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 14
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 14
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

GuokLiu

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值