您的位置:首页 > 编程语言 > Python开发

gvim支持python3编译,解决omnicppcomplete中python3complete报错:requried vim complied with +python3

2020-04-07 12:24 1841 查看

软件版本:

gvim82,python3.6,mingw-w64(gcc 8.1)

问题描述:

1、在_vimrc文件中添加:
autocmd Filetype python set omnifunc=python3complete#Complete
autocmd Filetype python inoremap <buffer>. .<C-X><C-O>
2、编辑hello.py文件,输入 sys. ,
便会报错requried vim complied with +python3

原因分析:

控制台输入gvim --version,可以看到-python,-python3。
-号表示不支持,+号表示支持。
原因是gvim8以后版本,安装包默认不支持python。
所以通过gvim源码编译生成gvim.exe时需要增加Python支持。

解决方案:

1、首先从官网(http://www.vim.org)下载vim82src源码,以及下载gvim82.exe安装包。
2、安装gvim82.exe,然后控制台输入gvim --version,可见-python3。
3、windows下需要安装mingw-w64(gcc编译环境),控制台输入mingw32-make --version保证安装成功。
4、源码vim82src/vim/vim82/src/INSTALLpc.txt,详细介绍了编译过程:
================================
Building with Python3 support

For building with MSVC the "Windows Installer" from www.python.org works fine.
Python 3.6 is recommended.

When building, you need to set the following variables at least:

PYTHON3:         Where Python3 is installed. E.g. C:\Python36
DYNAMIC_PYTHON3: Whether dynamic linking is used. Usually, set to yes.
PYTHON3_VER:     Python3 version. E.g. 36 for Python 3.6.X.

When using MinGW and link with the official Python3 (as one line):

mingw32-make -f Make_ming.mak
PYTHON3=C:/Python36 DYNAMIC_PYTHON3=yes PYTHON3_VER=36
================================
5、以下介绍我的编译过程:
(1)修改vim82src/vim/vim82/src/Make_cyg_ming.mak文件,查找ARCH,将其设置为ARCH=x86-64(注意删除#号)。
(2)控制台cd到vim82src/vim/vim82/src文件夹,然后执行:
mingw32-make -f Make_ming.mak PYTHON3=C:/Python36 DYNAMIC_PYTHON3=yes PYTHON3_VER=36 gvim.exe
需注意python的安装路径要修改。
6、将gvim.exe拷贝到vim82安装路径中,替换原有的。
7、控制台输入gvim --version,可以看到+python3。
8、打开hello.py,在输入sys.,即可实现自动补全。

如果要支持python2及其他语言的话,可以参考INSTALLpc.txt。
接下来,开始enjoy coding with vim!

  • 点赞 1
  • 收藏
  • 分享
  • 文章举报
JohnnyZ93 发布了2 篇原创文章 · 获赞 2 · 访问量 122 私信 关注
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: