第五节 重新安装vim python的开发环境

在系统重新安装后,本文详细记录了如何在CentOS上配置vim的Python开发环境,包括更换yum源为163源,安装Vundle.vim管理vim插件,以及解决安装YouCompleteMe代码补全工具时遇到的C++编译器、Python开发版等依赖问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

由于第四节的失败,重新安装了系统,再次配置一次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这个包,命令提示符下执行

yum install 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,就可以补全代码了

终于完成了,哈哈。。。。。













评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值