由于第四节的失败,重新安装了系统,再次配置一次vim python开发环境,以此做记录,希望一切顺利
1.先把yum源改为163
参考 http://mirrors.163.com/.help/centos.html
cd /etc/yum.repos.d
wget http://mirrors.163.com/.help/CentOS7-Base-163.repo
mv CentOS7-Base-163.repo CentOS-Base.repo
yum clean all
yum makecache
找到与系统版本对应的163目录
[root@localhost yum.repos.d]# cat /etc/redhat-release CentOS Linux release 7.5.1804 (Core)
我系统对就应镜像目录: http://mirrors.163.com/centos/7.5.1804/
由第四节的经验,yum不能找到的软件,从这里找。不会有错
2.在系统自带的python2.7上和vim7安装bundle
cd /usr/share/vim/vim7
因为我下了bundle的包直接改名为Vundle.vim放到了
/usr/share/vim/vim7/bundle
直接打开Vmi Bundle就安装好的
查看和使用见https://www.jianshu.com/p/297802d16fb4?from=timeline&isappinstalled=0
3.安装YouCompleteMe 代码补全工具
下载之间设置git的缓冲区 git config --global https.postBuffer 1048576000
不然下载会出错
remote: Counting objects: 34240, done. remote: Compressing objects: 100% (19/19), done. error: RPC failed; result=18, HTTP code = 200MiB | 43.00 KiB/s fatal: The remote end hung up unexpectedly fatal: early EOF fatal: index-pack failed
下载YouCompleteMe工具git clone --recursive https://github.com/Valloric/YouCompleteMe.git到
/usr/share/vim/vim7/bundle
下载完成后安装,进入YouCompleteMe目录执行install.py --all
由于我的centos是最小安装所以出错了
[root@localhost YouCompleteMe]# ./install.py --all ERROR: Unable to find executable 'cmake'. CMake is required to build ycm
安装 cmake
[root@localhost YouCompleteMe]# yum -y install cmake
安装完成后再次执行./install.py --all
提示错误:
CMake Error at CMakeLists.txt:239 (message):
Your C++ compiler does NOT fully support C++11.
没有安装gcc-c++
安装gcc-c++
再次编译
cm/ClangCompleter/ClangCompleter.cpp:29: /usr/share/vim/bundle/YouCompleteMe/third_party/ycmd/cpp/pybind11/pybind11/detail/common.h:111:20: fatal error: Python.h: No such file or directory #include <Python.h> ^ compilation terminated.
没有找到python头文件
参见 https://blog.youkuaiyun.com/ztm521/article/details/75014105
系统中没有python.h的原因,是因为没有安装python的开发版,即Python-devel这个包,命令提示符下执行
再次编译,编译完成。
配置vim自动补全代码
配置完成后,打开vim时出现错误
YouCompleteMe unavailable: requires Vim 7.4.1578+.
我的centos里装的是version 7.4.1099 ,啊...,悲剧,安装vim 8.0
git clone https://github.com/vim/vim.git./configure --with-features=huge -enable-pythoninterp --with-python-config-dir=/usr/lib/python2.7/config
make
make install
安装完成,再把/usr/share/vim下的bundle拷贝到/usr/local/share/vim目录下,再把咱们上页配置的/etc/vimrc拷贝到
/usr/local/share/vim
再启动/usr/local/bin/vim 就可以使用代码自动补全了。
cp ./vim /usr/bin/vipy
以后使用vipy来编辑python,就可以补全代码了
终于完成了,哈哈。。。。。